[R] helps on levelplot

Yan Wang yanw at stat.berkeley.edu
Wed Apr 28 08:35:26 CEST 2004


Thank you for the hints! I have some followup questions.

About the panel function, here is the code I copied from the example:
      xyplot(NOx ~ C | EE, data = ethanol,
             prepanel = function(x, y) prepanel.loess(x, y, span = 1),
             xlab = "Compression Ratio", ylab = "NOx (micrograms/J)",
             panel = function(x, y) {
                 panel.grid(h=-1, v= 2)
                 panel.xyplot(x, y)
                 panel.loess(x,y, span=1)
             },
             aspect = "xy")

My question is what is the relation between the xyplot function and 
panel.xyplot(x,y). In my case, I found that in the panel function, if I 
only have panel.abline(), the levelplot wouldn't be drawn at all. But I 
don't know how to specify the arguments in panel.levelplot(), which is 
exactly the part that you used "..." in your last reply. For all sorts 
of possible ways I tried, I got various of errors.

About the label size for the colorkey, when I coded as you suggested:
levelplot(z~x*y, grid,at=seq(0,1,by=0.1),scales=list(cex=2),
	colorkey=list(labels=list(cex=2, at=seq(0,1,by=0.1))))

I got error "Error in draw.colorkey(x$colorkey) : invalid type/length 
(3/1) in vector allocation". In fact, for whatever "at" I specified in 
labels, I got the same error message.

Further help is greatly appreciated.


Deepayan Sarkar wrote:

> 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