[R] plot just one page of lattice plot

From: Felix Andrews <felix_at_nfrac.org>
Date: Sun, 24 Jun 2007 19:38:06 +1000


Great stuff, thanks. I'm copying this solution to R-help for reference.

On 6/24/07, deepayan.sarkar_at_gmail.com <deepayan.sarkar_at_gmail.com> wrote:
> On 6/23/07, Felix Andrews <felix_at_nfrac.org> wrote:
> > Hi Deepayan,
> >
> > I have a Lattice question: is there any way to plot just one
> > (specified) page of a multi-page display?
>
> Not in those terms exactly. However, it is possible to plot subsets of
> a trellis object, e.g.
>
> p <- xyplot(y ~ x | a)
> # dim(p) is nlevels(a)
> p[1:3]
> p[4:6]
>
> p <- xyplot(y ~ x | a + b)
> # dim(p) is c(nlevels(a), nlevels(b))
> p[1:2, 3:4]
>
> etc. See also ?packet.panel.default (and ?print.trellis), which I just
> realized can be used to do what you want:
>
> packet.panel.page <- function(n)
> {
> ## returns a function that when used as the 'packet.panel'
> ## argument in print.trellis plots page number 'n' only
> function(layout, page, ...) {
> stopifnot(layout[3] == 1)
> packet.panel.default(layout = layout,
> page = page + n - 1,
> ...)
> }
> }
>
> data(mtcars)
> HP <- equal.count(mtcars$hp, 6)
> p <-
> xyplot(mpg ~ disp | HP * factor(cyl),
> mtcars, layout = c(0, 6, 1))
>
> print(p, packet.panel = packet.panel.page(1))
> print(p, packet.panel = packet.panel.page(2))
>
> In fact, I'm going to add this as an example in ?packet.panel.default
>
> -Deepayan
>

-- 
Felix Andrews / 安福立
PhD candidate, The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
voice:+86_1051404394 (in China)
mobile:+86_13522529265 (in China)
mobile:+61_410400963 (in Australia)
xmpp:foolish.android_at_gmail.com
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8

______________________________________________
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.
Received on Sun 24 Jun 2007 - 09:42:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 24 Jun 2007 - 11:32:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.