[R] accessing ylim set by xyplot

Powell, Jeff Jeff.Powell at wur.nl
Fri Oct 12 14:48:31 CEST 2007

I would like to know if there is a clever way to avoid the problem
illustrated below within the xyplot function.
x <- seq(1:10)
y <- seq(1:10)
pr1 <- xyplot(x ~ y) 

u <- seq(1:12)
v <- seq(1:12)
pr2 <- xyplot(u ~ v, col = "red", more = FALSE)
prts <- list(pr1, pr2)
for(i in prts) print(i, more = TRUE)
I realize that one possibility is to explicitly set the same values for
xlim and ylim for the plot, but that doesn't work very well for me
because I am accessing data via a function in a simulation loop in which
the ylims vary substantially depending on the variable being plotted. 
What I would like to be able to do is to access the limits that xyplot
automatically sets when it initially creates a plot and then use those
values to estimate a ylim for succeeding rounds of the simulation.  For
instance, if in the first round of a simulation the ylim set by xyplot
for a variable is c(0,20), I could then use that value as the ylim in
the following rounds for the same variable (other variables will be
assigned their limits accordingly).  At the end of the program I will
have plots for 20 or so variables with each plot having several 'lines'
for each round of the simulation.   
In short, is there a way to access the automatically determined ylim?
Kind regards,

More information about the R-help mailing list