[R] helps on levelplot

Deepayan Sarkar deepayan at stat.wisc.edu
Wed Apr 28 15:01:24 CEST 2004


On Wednesday 28 April 2004 01:35, Yan Wang wrote:
> 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.

I believe this is described in some detail in the documentation. Have 
you read the entry for 'panel' in help(xyplot) ?

Generally speaking, each lattice function has its own panel function -- 
e.g. panel.xyplot, panel.levelplot, etc. The arguments they accept may 
be different, and are described in their respective help pages. 
Naturally, any high level function (like xyplot and levelplot) will 
pass to its panel function enough information for the default panel 
functions to work. Another way to find out what arguments are passed 
would be to use 

panel = function(...) print(names(list(...)))

BTW, I would recommend always using a ... argument in your panel 
function definition.

I don't know if this answers your questions. If it doesn't please be 
more specific in describing where your confusion lies.

> 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.

Works for me as expected. Perhaps you are not using the latest R 
(1.9.0).

Deepayan




More information about the R-help mailing list