[R] xyplot with grid?

Gabor Grothendieck ggrothendieck at gmail.com
Wed May 9 21:52:45 CEST 2007


You can do it via panel= or after the fact with trellis.focus...trellis.unfocus.
The following illstrates both.  The panel= function adds a vertical line
at 3 and after the fact we add a vertical line at 6.

pnl <- function(...) {
   panel.abline(v = 3)
   panel.xyplot(...)
}

xyplot(x~y,data.frame(x=1:9,y=1:9,z=sort(rep(c('A','B','C'),3))),
    groups=z,auto.key=list(columns=3), panel = pnl)

trellis.focus("panel", 1, 1)
panel.abline(v = 6)
trellis.unfocus()



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? After calling the xyplot call, the panel.* functions seem to
> work only in device coordinates.
>
> Thanks for the help,
>
> Gav
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list