[R] lattice key inside panel

Dieter Menne dieter.menne at menne-biomed.de
Thu Feb 5 20:28:05 CET 2009


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?

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




More information about the R-help mailing list