[R] polygons around clusters of identically valued nodes in levelplot()

Deepayan Sarkar deepayan at stat.wisc.edu
Sat Jun 19 17:21:11 CEST 2004


On Monday 14 June 2004 15:58, Scott Waichler wrote:
> I'm looking for a way to plot lines on top of a levelplot(),
> where the lines are borders between cells of different values.
> The clines() function provides contours suitable for continuous
> data.  I am dealing with discrete values, spatial clusters of nodes
> where each cluster has an integer value, and I want to plot the
> borderlines between these areas.
> So, in a levelplot having nodes with values 0, 1, or 2, I would
> like to plot lines between nodes having the values 0 and 1, 0 and 2
> and 0 and 2. The contouring concept gives two lines for adjacent
> nodes having values of 0 and 1.

I don't entirely understand what you are trying to achieve (would it be 
something like voronoi lines?). In general, lines can be added to 
lattice panels using functions like llines, lsegments, etc. in a custom 
panel function, e.g., 

levelplot(z ~ x * y, ...
          panel = function(x, y, z, ...) {
              panel.levelplot(x, y, z, ...)
              ## do calculations on what lines you 
              ## want to draw, producing variables
              ## xx and yy, say
              llines(xx, yy)
          })

Hope that helps,

Deepayan




More information about the R-help mailing list