Chandan
Chandan

Reputation: 31

Specifying number of panels/line in Lattice

I have 16 panels that Lattice arranges in a 4x4 array. I need to arrange the panels such that the first or bottom line has panels 1-5, second line panels 6-11, and third or top line with panels 12-16. I'm not sure how to specify this and hoping someone can help.

Here are my data:

mydata <- data.frame(fac1 = rnorm(160,20,1),
          fac2 = sort(rep(c(1:16),10)),
          sub = as.factor(rep(c(1:16),5)))

And the 4x4 plot currently:

xyplot(fac1 ~ fac2 | sub, data = mydata, strip=FALSE,
  panel = function(x, y,...) {
  panel.xyplot(x, y,...)
  panel.text(15,18,labels=panel.number())
  }) 

Hoping someone can point me towards a layout parameter that allows me to specify which panels occur on which line of the overall plot display.

Upvotes: 2

Views: 211

Answers (1)

emudrak
emudrak

Reputation: 1016

Based on the second answer to this question,

I was able to get what I think you want with this:

xyplot(fac1 ~ fac2 | sub, data = mydata, strip=FALSE,
  panel = function(x, y,...) {
  panel.xyplot(x, y,...)
  panel.text(15,18,labels=panel.number())
  }, 
  layout=c(6,3), skip=c(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1)
  ) 

Upvotes: 1

Related Questions