Re: [R] xyplot with grid?

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Wed, 09 May 2007 19:34:45 +0100

On Wed, 2007-05-09 at 19:13 +0100, Gav Wood wrote:
> > Giving a reproducible example would be a good start.
>
> Ok, what's the easiest way to get a grid (ala grid()) on this graph?
>
> 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))
>
> Bish bosh,

Er, write your own panel function:

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), h = -1, v = -1,
       panel = function(x, y, ...) {
       panel.grid(...)
       panel.xyplot(x, y, ...)
     })

Not sure if that is the easiest way, or the best, but that's how I've learnt to use lattice recently. The v and h arguments are passed to panel.grid as part of "..." and just tell it to plot the grids at the tick marks.

>
> Gav

HTH Gav,

Gav

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
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 - 18:38:21 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 - 19:31:41 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.