Skip to content

color key with xyplot

3 messages · Deepayan Sarkar, Renaud Lancelot

#
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 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"))

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)
--- Renaud Lancelot <lancelot at sentoo.sn> wrote:
__________________________________________________



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Deepayan Sarkar wrote:
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.
It works great: it is exactly what I needed.

Thank you very much for your help,

Renaud