[R] Plotting multiple xyplots in same page

Lisa Daniel lisadaniel2013 at yahoo.com
Wed Feb 13 23:28:36 CET 2013


Dear Rhelp,

I would like to have 6 xyplots in the same page.  Similar to (par(mfrow=c(3,3))
Found this example on the R archives.
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
              groups = rowpos, type = "a",
              auto.key = list(x = 0.2, y = 0.9,
                cex = 0.75, points = FALSE, lines = TRUE))

print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)




When I changed the print() to:

 print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
the figure was not looking good.

Also, is it possible to assign A, B, C,D, etc for each figure. 



a<- rnorm(1000,0,1) 
b<- rnorm(1000,0,2) 
c<- rnorm(1000,0,3) 
d<- rnorm(1000,0,4) 
par(mfrow=c(2,2)) 
hist(a,main="") 
title(main="A",adj=0) 
hist(b,main="") 
title(main="B",adj=0) 
hist(c,main="") 
title(main="C",adj=0) 
hist(d,main="") 
title(main="D",adj=0)


I tried this to xyplot, but it was not working.

Please help me.  

Many thanks in advance,
Lisa.



More information about the R-help mailing list