[R] color key with xyplot

Renaud Lancelot lancelot at sentoo.sn
Fri Mar 29 10:18:15 CET 2002

Deepayan Sarkar wrote:
> Do you mean a colorkey as is usually drawn in levelplot (and not key) ?
> xyplot is not designed to draw color keys directly. You could use the key
> argument to xyplot to emulate it somewhat
> (something like key = list(rect = list(col = 1:7), space = "right"))

Yes, that's what I did as a workaround. But I use xyplot to draw
geographic maps (conditionally on season and other covariates) with many
polygons, color of which is used to represent the continuous variable of
interest. I thought a color key, just like in levelplot, would be easier
to handle than the regular key.

> Alternately, you could modify the object produced by xyplot to add a colorkey
> component, which would be enough to fool print.trellis:
> foo <- xyplot(<whatever>)
> foo$colorkey <- list(col = 1:7,  at = 1:8, tick.number = 10)
> print(foo)

It works great: it is exactly what I needed.

Thank you very much for your help,


> --- Renaud Lancelot <lancelot at sentoo.sn> wrote:
> > Dear all,
> >
> > I'd like to draw a color key beside a graph drawn with xyplot (lattice
> > library). I am aware of the draw.colorkey function (grid library) but
> > don't know how to handle it. Any hint would be appreciated.
> >
> > Renaud
> __________________________________________________
> Do You Yahoo!?

> http://movies.yahoo.com/

Dr Renaud Lancelot, vétérinaire
CIRAD, Département Elevage et Médecine Vétérinaire (CIRAD-Emvt)
Programme Productions Animales
http://www.cirad.fr/presentation/programmes/prod-ani.shtml (Français)
http://www.cirad.fr/presentation/en/program-eng/prod-ani.shtml (English)

ISRA-LNERV                      tel    (221) 832 49 02
BP 2057 Dakar-Hann              fax    (221) 821 18 79 (CIRAD)
Senegal                         e-mail renaud.lancelot at cirad.fr
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list