[R] pairs, panel.functions, xlim and ylim
Valeria Edefonti
vedefont at jhsph.edu
Wed Sep 22 17:39:56 CEST 2004
Hi,
I have the following problem.
I wanted to get a matrix of scatterplots and I used pairs.
I wanted to add the line y=x in each plot and I created a panel
function for this scope.
I used points and abline in the following way:
## put y=x in each plot
panel.lin<- function(x, y)
{
points(x,y, pch=21, bg=par("bg"), col = "black",cex=2)
abline(0,1,lwd=2, col="red")
}
and it works.
Now, I want that each plot has the same scale on the axis and I try
with this modification:
## put y=x in each plot - same scale for all the plots
panel.lincor<- function(x, y)
{
points(x,y, pch=21, bg=par("bg"), col =
"black",cex=2,xlim=c(-1,1),ylim=c(-1,1))
abline(0,1,lwd=2, col="red")
}
but R tells me that xlim and ylim couldn't be set in high level plot
functions.
I try to use plot() instead of points, but I realized immediately that
I can't use plot as a panel function.
I know I could have added xlim and ylim directly in pairs() function,
if I hadn't had a panel function, but I need the line y=x in every plot
and I don't know other ways to get it.
Any idea?
Thank you very much
Valeria Edefonti
More information about the R-help
mailing list