[R] lattice: how to add points to the plot generated by levelplot()?

Erik Iverson eriki at ccbr.umn.edu
Wed Mar 31 21:54:16 CEST 2010



Czerminski, Ryszard wrote:
> I am using levelplot() function from pkg:lattice and I want to add some
> points
> to the plot generated by levelplot()

It's best to include a small example of what you have done so far, and 
what you want to further do.  Actual R code with a small sample dataset 
is great.


> similarly as in basic R graphic sequence: plot(...); points(...),
> but it does not work.
> 
> I was reading documentation for lattice, but so far without much
> success.
> 
> I would very much appreciate some tips.


Most base graphics functions like point have a grid equivalent.  In this 
case, use grid.points.

  levelplot(runif(100)~runif(100)*runif(100),
                panel = function(...) {
                  panel.levelplot(...)
                  grid.points(.1, .1, pch = 2)
                  })


I found the Lattice book and the "R Graphics" book invaluable, both are 
worth getting.



More information about the R-help mailing list