| clines {clines} | R Documentation |
Produces a list of contours. Each contour is a list of 3 elements: the contour level, the x-coordinates of the contour, and the y-coordinates of the contour.
clines(x, y, z, nlevels = 10, levels = pretty(range(z, na.rm = TRUE), nlevels))
x,y |
locations of grid lines at which the values in z are
measured. These must be in ascending order. By default, equally
spaced values from 0 to 1 are used. If x is a list,
its components x$x and x$y are used for x
and y, respectively. If the list has component z this
is used for z. |
z |
a matrix containing the values to be plotted (NAs are
allowed). Note that x can be used instead of z for
convenience. |
nlevels |
number of contour levels desired iff
levels is not supplied. |
levels |
numeric vector of levels at which to draw contour lines. |
A list of contours. Each contour consists of:
1 |
The contour level. |
2 |
The x-coordinates of the contour. |
3 |
The y-coordinates of the contour. |
This function was just a temporary interface to the C code
underlying the contour function. There is now a base
function called contourLines which should be used instead.
Paul Murrell
# Mount Maungawhau
data("volcano")
rx <- range(x <- 10*1:nrow(volcano))
ry <- range(y <- 10*1:ncol(volcano))
ry <- ry + c(-1,1) * (diff(rx) - diff(ry))/2
tcol <- terrain.colors(12)
plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
u <- par("usr")
rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
line.list <- clines(x, y, volcano)
contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE,
vfont = c("sans serif", "plain"))
templines <- function(clines) {
lines(clines[[2]], clines[[3]])
}
invisible(lapply(line.list, templines))