[R] levelplot add line

Deepayan Sarkar deepayan at stat.wisc.edu
Wed Feb 25 01:51:48 CET 2004


On Tuesday 24 February 2004 18:03, Jeff Jorgensen wrote:
> R folks,
>
> I can't seem to find the instructions in the help files for the lattice
> package that explain how to add lines, such as with lines() or ?, to a
> levelplot.  I'd be grateful if someone could point me in the proper
> direction.

The general rule for all lattice functions is to write your own panel 
function. For example, 

data(volcano)
levelplot(volcano, 
          panel = function(...) {
              panel.levelplot(...)
              panel.abline(c(0,1))
          })

lines() will not work for lattice, but you can use llines() instead. 

Of course, for anything more useful than this example, your panel function 
should make use of the data that's passed to the panel function. Exactly 
what would be passed depends on the function in question. For levelplot, 
the best place to look will be panel.levelplot, and similarly for other 
functions.

Hth,

Deepayan




More information about the R-help mailing list