Scott Waichler
2004-Jun-14 20:58 UTC
[R] polygons around clusters of identically valued nodes in levelplot()
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. Thanks, Scott Waichler Pacific Northwest National Laboratory Richland, Washington, USA scott.waichler at pnl.gov
Deepayan Sarkar
2004-Jun-19 15:21 UTC
[R] polygons around clusters of identically valued nodes in levelplot()
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