[R] lattice key inside panel

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Feb 5 21:28:55 CET 2009


On Thu, Feb 5, 2009 at 11:28 AM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
> Deepayan Sarkar <deepayan.sarkar <at> gmail.com> writes:
>
>> > One other thing that has so far eluded me is how to specify two
>> > different kinds of symbols on a single column. The key above shows
>> >
>> > text line text rectangle
>> >
>> > but I would really like to get
>> >
>> > text line
>> > text rectangle
>> >
>> > but this did not seem possible to me. Am I wrong?
>>
>> Not possible with draw.key(), but legends can be arbitrary grobs, so
>> you could construct a suitable one.
>
> I would have guessed that columns=2 would work, but you are right,
> it given an error message (Not enough rows for columns). Why?

It's a warning, not an error. 'columns' are meant to spread out
multiple rows into several "column blocks", but there is only one row
here.

-Deepayan

>
> Dieter
>
> xyplot(1~1,
>       panel = function(...) {
>           require(grid)
>           panel.xyplot(...)
>           draw.key(list(text=list(lab='catch'),
>                         columns=2,
>                         lines=list(lwd=c(2)),
>                         text=list(lab='landings'),
>                         rectangles=list(col=rgb(0.1, 0.1, 0, 0.1))),
>                  draw = TRUE,
>                  vp = viewport(x = unit(0.75, "npc"), y = unit(0.9, "npc")))
>       })
>
> ______________________________________________
> R-help at r-project.org 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.
>




More information about the R-help mailing list