[R] legend problems in lattice

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Sep 7 13:26:57 CEST 2006



Ernst O Ahlberg Helgee wrote:
> Hi!
> Im sorry to bother you but I cant fix this.
> I use the lattice function levelplot and I want the colorkey at the 
> bottom, how do I get it there? I have tried changing colorkey.space and 
> changing in legend but I cant get it right, plz help
> 
> btw I'd like to speceify strings to appear at the tick marks and also 
> there I fail any thoughts?
> 
> cheers
> Ernst
> 
> ______________________________________________
> 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.

Hi, Ernst,

Please read ?levelplot. Under the argument for "colorkey" you will see:

colorkey: logical specifying whether a color key is to be drawn
           alongside the plot, or a list describing the color key. The
           list may contain the following components:


           'space': location of the colorkey, can be one of '"left"',
                '"right"', '"top"' and '"bottom"'.  Defaults to
                '"right"'.


So the answer to your first question is:

levelplot(..., colorkey = list(space = "bottom"))

For your second question, use the "scale" argument. See ?xyplot for 
details. For example,

levelplot(..., scale = list(x = list(at = 1:4, labels = letters[1:4])))

HTH,

--sundar



More information about the R-help mailing list