Skip to content
Prev 167491 / 398502 Next

lattice question: independent per-row or per-column scaling?

On 1/19/2009 8:51 AM, hadley wickham wrote:
The argument for xlim or ylim can be a list.  Here is the key part of
the help page for xyplot:

xlim could also be a list, with as many components as the number of
panels (recycled if necessary), with each component as described above.
This is meaningful only when scales$x$relation is "free" or "sliced", in
which case these are treated as if they were the corresponding limit
components returned by prepanel calculations.

  Here is a little example:

library(lattice)

mdf <- data.frame(X1 = rep(LETTERS[1:3], each = 100*2*3),
                  X2 = rep(c("J","K"), 900),
                  X3 = rep(LETTERS[24:26], 100*3*2),
                  Y = c(runif(600, min=.01,max=.32),
                        runif(600, min=.33,max=.65),
                        runif(600, min=.66,max=.99)))

bwplot(Y ~ X3 | X2*X1, data = mdf,
       layout=c(2,3,1),
       ylim=as.data.frame(matrix(c(.01,.32,
                                   .01,.32,
                                   .33,.65,
                                   .33,.65,
                                   .66,.99,
                                   .66,.99), nrow=2)),
       scales=list(y=list(relation="free")))