Skip to content

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

7 messages · Deepayan Sarkar, Hadley Wickham, Chuck Cleland +1 more

#
Hello - and happy newyear to all of you!

I've got some data that I'm plotting with bwplot, a 3x2x3 design where
the observable decreases with the principle independent factor, but at
different rates.

I'd like to get lattice to impose not a single set of axes ranges
identical for all panels, but ranges that are identical for each panel
row or each column. Effects will stand out much better like that.

I've looked through the documentation of the latest lattice version,
but I don't see a way to achieve this with a simple argument passed to
bwplot. Can it be done otherwise and if so, how?

Thanks,
Ren? Bertin
10 days later
#
On 1/8/09, Ren? J.V. Bertin <rjvbertin at gmail.com> wrote:
There is no built in way to do this. You could use scales="free" and
provide explicit axis limits.

-Deepayan
#
On Thu, Jan 8, 2009 at 11:25 AM, Ren? J.V. Bertin <rjvbertin at gmail.com> wrote:
It's not lattice, but you can do this with ggplot2 - see the examples
for http://had.co.nz/ggplot2/facet_grid.html

Regards,

Hadley
#
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")))

  
    
#
Thanks for all the answers. I'll have a look at ggplot2. I'd seen the
possibility to set panel-specific limits via ylim, but I was in fact
looking for a switch to achieve non-global automatic scaling.

Given the fact that there is no built in provision for that, I take it
it's a functionality that isn't (considered) very interesting for most
lattice users, but out of curiosity, how difficult would it be to
implement it?

Ren?

INRETS - LEPSIS
#
Thanks for all the answers. I'll have a look at ggplot2. I'd seen the
possibility to set panel-specific limits via ylim, but I was in fact
looking for a switch to achieve non-global automatic scaling.

Given the fact that there is no built in provision for that, I take it
it's a functionality that isn't (considered) very interesting for most
lattice users, but out of curiosity, how difficult would it be to
implement it?

Ren?

INRETS - LEPSIS
4 days later
#
On Mon, Jan 19, 2009 at 7:24 AM, Ren? J.V. Bertin <rjvbertin at gmail.com> wrote:
Fairly hard. The problem is that lattice conceptually separates the
array-like structure defined by the conditioning variables, and the
array-like structure defined by the layout. It makes sense to relate
them when you have exactly two conditioning variables (and the
corresponding layout), but not otherwise. For example, what you want
will not be sensible if you have a single conditioning variable with,
say, 12 levels, and you plot the panels in a 3x4 layout.

Unfortunately, this makes row/column scaling difficult to do even when
it makes sense. On the other hand, it should not be too hard to write
a general wrapper (similar to 'useOuterStrips' in latticeExtra) that
automates most of the tedious work.

-Deepayan