Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] Place more than one key with xyplot

Deepayan Sarkar

2005-02-24

Replies:

On Thursday 24 February 2005 06:12, Gesmann, Markus wrote:
> Dear R-users
>
> I have some trouble to generate more than one key with xyplot using
> the legend argument.
> I would like one key with rectangles:
>
> library(lattice)
> library(grid)
> key1 <- list(rectangles = list(col= c(rev(heat.colors(5))[1:5],
>                       rev(heat.colors(5))[4:1])),
>              title="Percentiles",
>              space="right",
>              text = list(lab = rev(c(" 5-15", "15-25",
> "25-35", "35-45",
>                       "45-55","55-65", "65-75", "75-85",
> "85-95"))),
>              columns = 1)
>
> and another one with lines:
>
> key2 <- list(lines=list(col=2), text=list(lab="Mean"))
>
> Each of them works fine:
>
> xyplot(1~1, key = key1)
> xyplot(1~1, key = key2)
>
> Unfortunately I don't really understand which "fun" (for legend) I
> have to use.
> The following line does not work.
>
> xyplot(1~1, legend = list(right=list(key1, fun="grob"),top=list(key2,
> fun="grob")))

You want

xyplot(1~1,
    legend = list(right = list(fun="draw.key",
                args = list(key = key1, draw = FALSE)),
             top = list(fun="draw.key",
                args = list(key = key2, draw = FALSE))))

?draw.key should explain why.

Deepayan

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.