contourLines
Calculate Contour Lines
Description
Generates a list of contour lines; plots nothing.
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 |
a vector containing x coordinates of the grid over which z is evaluated.
The values must be in strictly increasing order. Missing values are not accepted.
It should have one value for each row of z.
|
y |
a vector of grid y coordinates.
The values must be in strictly increasing order. Missing values are not accepted.
It should have one value for each column of z.
|
z |
a matrix of size length(x) by length(y) giving the surface height at grid points.
|
nlevels |
the approximate number of contour intervals desired.
|
levels |
a vector of the heights of the contour lines.
|
Details
- If the x argument is a list with components x and y, then
those are used as the usual x and y arguments to contourLines.
That is, contourLines(list(x=x, y=y), z=matrix) is equivalent to contourLines(x, y, z).
- If the x argument is a matrix, and if there is no y argument, then x is
used as the usual z argument. That is, contourLines(matrix) is equivalent
to contourLines(z=matrix).
Value
returns an invisible list of contour lines, each of which contains the following components.
level |
the contour level.
|
x |
the x coordinates of points on a contour at the given level.
|
y |
the y coordinates of points on a contour at the given level.
|
There might be many contour lines at each level. If a contour forms
a loop, then its last point is identical to its first.
There is one point output each time a grid line (based on the
input
x and
y values) crosses the given level.
If a crossing would fall where grid lines cross, then it is pushed
downward a tiny bit.
Note
The TIBCO Enterprise Runtime for R version orients the contour line segments so that the downhill
is to the left of each segment. That is, they go clockwise around hills
and counterclockwise around holes. The R version does not give a consistent
orientation.
See Also
Examples
x <- c(1,3,6)
y <- c(11,12,17)
z <- cbind(c(1,2,6),c(3,7,6),c(2,5,8))
str(contourLines(x, y, z, levels=6.5))