Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling placement of empty lattice panels

Tags:

r

lattice

When plotting fewer panels than the full grid you get a gap without a panel. Most lattice functions puts the gap in the top right, but I would like to have it in the lower right, as marginal.plot does (see the picture). Is there a way to make other lattice functions do the same?

Example from the marignal.plot help page

I know the panel order is decided by the order of the factor levels of the conditioning variable, or by using the index.cond argument, but that does not help me here. I have tried to decipher the code of marginal.plot, but haven't been able to figure it out, so any help is appreciated!

like image 759
Backlin Avatar asked Jul 13 '12 09:07

Backlin


2 Answers

The as.table= argument is really there to let users specify the corner from which laying down of panels begins (i.e. top-left or bottom-left). It thus gives you only limited and incidental control over where panels are and are not plotted.

For greater control over panel placement, use the skip= argument (perhaps in concert with as.table=TRUE):

# 'skip' plotting of the central panel.
# Note: skip <- c(0,0,0,0,1,0,0,0,0) or even 'skip <- 1:9 %in% 5' would also work
skip <- c(F,F,F,F,T,F,F,F,F) 
xyplot(lat ~ long | Depth, data = quakes, skip = skip, layout = c(3,3))

enter image description here

like image 94
Josh O'Brien Avatar answered Sep 28 '22 01:09

Josh O'Brien


The as.table=TRUE option should do this for most lattice plots by filling in the top row first instead of the bottom row.

like image 22
Aaron left Stack Overflow Avatar answered Sep 28 '22 00:09

Aaron left Stack Overflow