[R] lattice: plotting an arbitrary number of panels, defining arbitrary groups

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Aug 27 21:56:24 CEST 2008


On Tue, Aug 26, 2008 at 6:56 PM, Alex Karner <aakarner at ucdavis.edu> wrote:
> Thanks Deepayan, works like a charm.
>
> A followup question though--I'd like to produce the same data on four
> panels with the final two "zoomed in", i.e. plotted with shorter x and
> y axes. Since I can't access panel.number in the prepanel function,
> and since updating the plot with lists of the new x and y axis ranges
> via xlim and ylim doesn't work (I think since I only actually have one
> repeated panel),

There is no simple way to do this. The lattice model associates axis
limits with packets (data subsets that go in panels) and not panels
(i.e., if two or more panels display the same packet, they will also
have the same limits). One way to work around this is to override the
default axis annotation. The easier solution is to make a second copy
of your data. E.g.,

dataSet2 <-
    make.groups(full = dataSet,
                sub = subset(dataSet, Value > y1 & Value < y2 &
Detector > x1 & Detector < x2))


p <- xyplot(Value ~ Detector | which, dataSet2, scales = "free")

and then proceed as before.

-Deepayan



More information about the R-help mailing list