[R] helps on levelplot

Deepayan Sarkar deepayan at stat.wisc.edu
Wed Apr 28 00:38:55 CEST 2004


On Tuesday 27 April 2004 16:43, Yan Wang wrote:
> I'm a new user of levelplot, and are not familiar with the
> terminology very well. Is the bar alongside the levelplot indicating
> color or shade call "colorkey"? I have to adjust the size of its
> label, but couldn't make it so far. This is how I did:
>
> levelplot(z~x*y, grid, at=seq(0,1,by=0.1),
> colorkey=list(labels=list(cex=2)))
>
> But I got error message "Error in draw.colorkey(x$colorkey) : Object
> "at" not found". I tried to specify "at" in colorkey too, but it
> didn't help.

Looks like a bug. For a workaround, you need to specify at in the labels 
component, not in colorkey (both are allowed), e.g.

colorkey=list(labels=list(cex=2, at=<whatever>))

> A second task I have to do is to add horizontal and vertical lines on
> the levelplots, just like the way that ablines() works for image().
> ablines doesn't work for levelplot. Any help will be much
> appreciated.

Use panel.abline, in the same way panel functions work in all lattice 
functions. e.g.,

levelplot(matrix(1:20, 4, 5), 
          panel = function(...) {
              panel.levelplot(...)
              panel.abline(h = 3.2)
          })

Deepayan




More information about the R-help mailing list