contourLines
Calculate Contour Lines
Description
Calculate contour lines for a given set of data.
Usage
contourLines(x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, length.out = ncol(z)), z, nlevels = 10, levels = pretty(range(z, na.rm = TRUE), nlevels))
Arguments
x, y | locations of grid lines at which the values in |
z | a matrix containing the values to be plotted ( |
nlevels | number of contour levels desired iff |
levels | numeric vector of levels at which to draw contour lines. |
Details
contourLines
draws nothing, but returns a set of contour lines.
There is currently no documentation about the algorithm. The source code is in ‘R_HOME/src/main/plot3d.c’.
Value
A list
of contours, each itself a list
with elements:
level | The contour level. |
x | The x-coordinates of the contour. |
y | The y-coordinates of the contour. |
See Also
options("max.contour.segments")
for the maximal complexity of a single contour line.
contour
: Its ‘Examples’ demonstrate how contourLines()
can be drawn and are the same (as those from contour()
).
Examples
x <- 10*1:nrow(volcano) y <- 10*1:ncol(volcano) cl <- contourLines(x, y, volcano) ## summarize the sizes of each the contour lines : cbind(lev = vapply(cl, `[[`, .5, "level"), n = vapply(cl, function(l) length(l$x), 1)) z <- outer(-9:25, -9:25) pretty(range(z), 10) # -300 -200 ... 600 700 utils::str(c2 <- contourLines(z)) # no segments for {-300, 700}; # 2 segments for {-200, -100, 0} # 1 segment for 100:600
Copyright (©) 1999–2012 R Foundation for Statistical Computing.
Licensed under the GNU General Public License.