Re: [R] xyplot with grid?

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Wed, 09 May 2007 12:55:48 -0700

On 5/9/07, Gav Wood <news_at_gavofyork.fastmail.fm> wrote:
> Gabor Grothendieck wrote:
> > Add the argument
> >
> > type = c("p", "g")
> >
> > to your xyplot call.
>
> So what's the easiest way to place a line at x=3 (ala "abline(v=3)") to
> the graph?

xyplot(x~y,data.frame(x=1:9,y=1:9,z=sort(rep(c('A','B','C'),3))),

       type = c("p", "g"),
       panel = function(...) {
           panel.xyplot(...)
           panel.abline(v = 3)
       },
       groups=z,auto.key=list(columns=3))

or

xyplot(x~y,data.frame(x=1:9,y=1:9,z=sort(rep(c('A','B','C'),3))),

       panel = function(...) {
           panel.grid(h = -1, v = -1)
           panel.abline(v = 3)
           panel.xyplot(...)
       },
       groups=z,auto.key=list(columns=3))

depending on whether you are going through the intermediate example or not.

> After calling the xyplot call, the panel.* functions seem to
> work only in device coordinates.

No, they work in native coordinates, you just happen to be in a "viewport" where they are the same as the device coordinates. Note that your expectations seem to be based on the traditional graphics model with only one panel, which is not meaningful in multipanel plots, like, say,

xyplot(x~y|z,data.frame(x=1:9,y=1:9,z=sort(rep(c('A','B','C'),3))))

If you wish to modify a lattice plot after it has been plotted (which is justifiable only in circumstances where you want some sort of interaction), see

?trellis.focus

-Deepayan



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 Wed 09 May 2007 - 20:01:32 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 Wed 09 May 2007 - 20:33:27 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.