rhelp.20.trevva at spamgourmet.com
2007-Jun-07 09:40 UTC
[R] Display Multiple page lattice plots
Gudday, I am generating a series of lattice contourplots that are conditioned on a variable (Year) that has 27 different levels. If I try and put them all on one plot, it ends up pretty messy and you can't really read anything, so instead I have set the layout to 3x3, thus generating three pages of nine plots each. The problem is that I can't display all these on screen at once, because each subsequent page overwrites the previous one. I have found in the mailing lists how to print them to separate files without any problems eg. p<-contourplot(log10(x)~lat*long|Year, data=data.tbl, layout=c(3,3)) png(file="Herring Distribution%02d.png",width=800,height=800) print(p) dev.off() but there doesn't seem to be anything about how to output multiple pages to the screen... I suspect that I may need to use the page=... option in contourplot command, but I can't seem to make it work. Its a simple, and not particularly important problem, but it sure is bugging me! Thanks for the advice in advance. Cheers, Mark
This works on my Windows machine starting off at a new R session: options(graphics.record = TRUE) library(lattice) xyplot(uptake ~ conc | Plant, CO2, layout = c(2,2)) Now switch focus to the graphics window and you can PgUp and PgDn through them. There are several variations to this: 1. use graphics.record option as shown above 2. the graphics.record option is passed to the windows driver so explicitly call windows yourself. See ?windows 3. prior to your xyplot switch focus to the graphics window and a History menu appears. Use that to turn on recording. On 6/7/07, rhelp.20.trevva at spamgourmet.com <rhelp.20.trevva at spamgourmet.com> wrote:> Gudday, > > I am generating a series of lattice contourplots that are conditioned on a variable (Year) that has 27 different levels. If I try and put them all on one plot, it ends up pretty messy and you can't really read anything, so instead I have set the layout to 3x3, thus generating three pages of nine plots each. The problem is that I can't display all these on screen at once, because each subsequent page overwrites the previous one. I have found in the mailing lists how to print them to separate files without any problems eg. > > p<-contourplot(log10(x)~lat*long|Year, > data=data.tbl, > layout=c(3,3)) > png(file="Herring Distribution%02d.png",width=800,height=800) > print(p) > dev.off() > > but there doesn't seem to be anything about how to output multiple pages to the screen... I suspect that I may need to use the page=... option in contourplot command, but I can't seem to make it work. Its a simple, and not particularly important problem, but it sure is bugging me! > > Thanks for the advice in advance. > > Cheers, > > Mark > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
On 6/7/07, rhelp.20.trevva at spamgourmet.com <rhelp.20.trevva at spamgourmet.com> wrote:> Gudday, > > I am generating a series of lattice contourplots that are conditioned on a variable (Year) that has 27 different levels. If I try and put them all on one plot, it ends up pretty messy and you can't really read anything, so instead I have set the layout to 3x3, thus generating three pages of nine plots each. The problem is that I can't display all these on screen at once, because each subsequent page overwrites the previous one. I have found in the mailing lists how to print them to separate files without any problems eg. > > p<-contourplot(log10(x)~lat*long|Year, > data=data.tbl, > layout=c(3,3)) > png(file="Herring Distribution%02d.png",width=800,height=800) > print(p) > dev.off() > > but there doesn't seem to be anything about how to output multiple pages to the screen... I suspect that I may need to use the page=... option in contourplot command, but I can't seem to make it work. Its a simple, and not particularly important problem, but it sure is bugging me! >You haven't told us what you want to happen exactly. Gabor's solution will work (on Windows), and a multi-page PDF file is a similar option that's portable. Here's another option if you want multiple windows: xyplot(1:10 ~ 1:10 | gl(3, 1, 10), layout = c(1, 1), page function(n) dev.copy(x11)) you should replace x11 with the appropriate choice on your platform. This will produce an extra copy of the last page, which you can suppress by making use of 'n' inside your page function. (Unfortunately page = function(n) x11() does not work, even though that would have been more natural.) Another option is to print your trellis object in parts; e.g. p<-contourplot(log10(x)~lat*long|Year, data=data.tbl, layout=c(3,3)) x11() p[1:9] x11() p[10:18] x11() p[19:27] -Deepayan