[R] lattice multi-panel layout

Duncan Mackay dulcalma at bigpond.com
Fri Oct 4 01:35:48 CEST 2013


Hi  
Have a look at ?print.trellis. Lattice (xyplot) is not like plot

Untested.

starting at bottom left going across the rows

print(plott[[4]], position = c(0,0,1/3,0.5), more = T)
print(plott[[5]], position = c(1/3,0,2/3,0.5), more = T)
print(plott[[6]], position = c(2/3,0,1,0.5), more = T)
print(plott[[1]], position = c(0,0.5,1/3,1), more = T)
print(plott[[2]], position = c(1/3,0.5,2/3,1), more = T)
print(plott[[3]], position = c(2/3,0.5,1,1), more = T)

or you could go into viewports  ?viewport

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of efx
Sent: Thursday, 3 October 2013 23:25
To: r-help at r-project.org
Subject: [R] lattice multi-panel layout

Dear,
I seem to be unable to work out a solution for multi-panel layout using
xyplot. I have tried with layout, grid.layout (latticeExtra), but
unsuccessfully. I can produce all plots individually, but just can't figure
out how to put them all in the same panel! Here is a piece of the code. 

vlayout <- grid.layout(2,3,widths=unit(2,"inches"), heights=unit(1.5,
"inches")) 

lapply(seq(vh), function(i) {
                 for (k in 1:num_bins){
                 indexx <- which(vh[[i]]$dist<= (k*radius/num_bins) &
vh[[i]]$dist> ((k-1)*radius/num_bins))
                 bin_avg[k]<-mean(vh[[i]]$gamma[indexx])      } 
              
  plott[[i]] <- xyplot(   bin_avg ~ dist , type=("p"),  layout= vlayout) 
) } )

 - If I use grid.layout I got the error: "Error in panel.layout[1] *
panel.layout[2] : 
  non-numeric argument to binary operator"
 - If set just layout as c(2,3) all plots are drawn in the bottom left of
the panel!!!
 - If layout is not set at all, all plots are produced in different pages.

I would be grateful if you could help me out.
Regards





--
View this message in context:
http://r.789695.n4.nabble.com/lattice-multi-panel-layout-tp4677500.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.



More information about the R-help mailing list