Frank Harrell
2013-Dec-21  23:18 UTC
[R] Possible to vary widths and/or heights of lattice panels?
Is it possible to vary the size of the panels in lattice within one page? The examine I have in mind is a 3 row by 2 column display where I vary the y-axis scales in a dot plot and there are only a few levels on the y-axis for one of the rows. I'd like to remove wasted space in that row. On a related issue http://stackoverflow.com/questions/9654244/multipage-lattice-panel-arrangement has some good information. Thanks for any pointers. Frank
Richard M. Heiberger
2013-Dec-22  02:45 UTC
[R] Possible to vary widths and/or heights of lattice panels?
library(latticeExtra) ?resizePanels On Sat, Dec 21, 2013 at 6:18 PM, Frank Harrell <f.harrell at vanderbilt.edu> wrote:> Is it possible to vary the size of the panels in lattice within one page? > The examine I have in mind is a 3 row by 2 column display where I vary the > y-axis scales in a dot plot and there are only a few levels on the y-axis > for one of the rows. I'd like to remove wasted space in that row. > > On a related issue > http://stackoverflow.com/questions/9654244/multipage-lattice-panel-arrangement > has some good information. > > Thanks for any pointers. > Frank > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Duncan Mackay
2013-Dec-22  03:17 UTC
[R] Possible to vary widths and/or heights of lattice panels?
Hi Frank
I am not sure what you need as there are various alternatives
for starters 
?latticeExtra::combineLimits
see 
http://finzi.psych.upenn.edu/R/Rhelp02/archive/43612.html
http://finzi.psych.upenn.edu/R/Rhelp02/archive/43626.html
I tried to check that these were the correct urls but I do not know if the
server is down.
This is Deepyan's code
xyplot(as.numeric(variety) ~ yield | year * site, data = barley,
       layout = c(6,2),
       scales = list(y = list(relation = "free",
                              rot = 0,
                              limits = rep(list( c(0, 6),   c( 5, 11 )),
c(6, 6)),
                              at     = rep(list( 1:5, NULL, 6:10, NULL ),
c(1, 5, 1, 5) ))),
       par.settings = list(layout.widths = list(axis.panel = rep(c(1, 0),
c(1, 5))))
)
Below is some code and templates for plots. I have stripped them down as
they are very long to get what I wanted particularly the large graph which
fitted on an A4 page
# varying ylimits
*********
# part of an a graph 5 rows x 7 cols
xyplot(GrowthMJ+I(SuppMJ+75)+GrowSuppMJ+Demand+Balance ~ Date, data balance,
       as.table = T,
       layout   = c(1, 5),
       outer    = TRUE,
       groups   = gFarm,
       strip    = FALSE,
       par.settings = list(layout.heights = list(panel
c(55,15,55,20,60)/sum(c(55,15,20,55,60))) ), # see below
       scales   = list(x = list(alternating = FALSE),
                       y = list(alternating = FALSE,
                                relation    = "free",
                                axs         = "i",
                                limits      = list(c(0,55000),
                                                   c(0, 5000),
                                                   c(0,55000),
                                                   c(0,20000),
                                                   c(-10000,50000) ),
                                at          = list(seq(0,50000,10000),
                                                   seq(0, 4000, 2000),
                                                   seq(0,50000,10000),
                                                   seq(0,15000, 5000),
                                                   seq(-10000,40000,10000)
),
                                labels      = list(as.character(seq(0,50,10)
),
                                                   as.character(seq(0, 4, 2)
),
                                                   as.character(seq(0,50,10)
),
                                                   as.character(seq(0,15, 5)
),
 
as.character(seq(-10,40,10)) ),
                                rot         = 0)
                   ), 
# vary the panel heights: if limits c(0, max) then take max values for all
row limits and divide by sum 
# If missing panels
# 3x3
coln <- number of columns
rown <- number of rows
par.settings = list(layout.heights = list(panel = 1), # vary the panel
heights: 
...                                                                     
scales = limits(y = list(
   limits = rep(list(c(0,1), c(0,2), c(0,3)), ea = ncol),
   at     = rep(list(seq(0,1,0.5), NULL, seq(0,2,0.5), NULL, seq(0,3,1),
NULL), rep(c(1,ncol-1), nrow)),
   labels = rep(list(seq(0,1,0.5), NULL, seq(0,2,0.5), NULL, seq(0,3,1),
NULL), rep(c(1,ncol-1), nrow))),
# varying xlimits
*********
# part of an example  3 x 3 panels
library(latticeExtra)
useOuterStrips
xyplot(GLoss+DLoss+LLoss ~ SRday|Farm,  meb,
outer    = TRUE,
par.settings = list(layout.widths = list(panel = c(0.25, 0.25, 0.5)), # sum
to 1 to vary the widths
scales   = list(x = list(alternating = FALSE,
                         relation    = "free",
                         limits = rep(list(c(-30, 250),
                                           c(-30, 250),
                                           c(-30, 550)), 3),
                         at    = rep(list(NULL,
                                           seq(0, 200, by = 50),
                                           seq(0, 200, by = 50),
                                           seq(0, 500, by = 100)),
                                           c((3-1)*3, rep(1, 3)) ),
                         labels = rep(list(NULL,
                                           paste(seq(0, 200, by = 50)),
                                           paste(seq(0, 200, by = 50)),
                                           paste(seq(0, 500, by = 100))),
                                           c((3-1)*3, rep(1, 3)) ),
                         axs = "i",
                         rot         = 0),
                y = list(alternating = FALSE,
                         relation    = "same",
                         rot         = 0)
            ),
If you want further information you can contact me offline
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of Frank Harrell
Sent: Sunday, 22 December 2013 09:19
To: RHELP
Subject: [R] Possible to vary widths and/or heights of lattice panels?
Is it possible to vary the size of the panels in lattice within one page?
The examine I have in mind is a 3 row by 2 column display where I vary the
y-axis scales in a dot plot and there are only a few levels on the y-axis
for one of the rows.  I'd like to remove wasted space in that row.
On a related issue
http://stackoverflow.com/questions/9654244/multipage-lattice-panel-arrangeme
nt
has some good information.
Thanks for any pointers.
Frank
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.