rsm.lm
contour(x, ...) contour.default(x, y, z, nlevels=5, levels=pretty(z, nlevels), add=F, labex=1, save=F, plotit=!save, triangles=F)
z
is evaluated.
The values must be in increasing order, and missing values are not accepted.
length(x)
by
length(y)
giving the surface
height at grid points, i.e.,
z[i,j]
is evaluated at
x[i]
,
y[j]
. The rows of
z
are indexed by
x
, and the columns by
y
. Missing values (
NA
s) are allowed, but should generally not occur in the
convex hull of the non-missing values.
x
,
y
, and
z
.
In particular, the result of
interp
is suitable as an argument to
contour
.
z
matrix and vectors
x
and
y
are generated (
x
is 1:nrow(z),
y
is 1:ncol(z)). The result of
predict
together with
expand.grid
is
suitable as an argument to
contour
.
levels
is specified.
(For compatibility with the old contour function
you may call this argument
nint
.)
nlevels
lines are drawn which cover the
range of
z
. (For compatibility with the old contour function
you may call this argument
v
.)
TRUE
(and
plotit
is
TRUE
),
contour lines are added to the
current plot. Use this to add contours with a different
labex
parameter, line type, etc., or to add contours to
some other type of plot.
cex
parameter.
TRUE
, then the coordinates of the contour lines will
be returned.
TRUE
, the contour plot will be plotted.
You should set at least one of
save
and
plotit
to
TRUE
.
xlab
and
ylab
to
""
to get no labels.
In addition, the high-level graphics arguments described under
and the arguments to
may be supplied to this function.
save
is
FALSE
.
save
is
TRUE
, then the output structure will be a list whose
length is the number of contour intervals. The names
of the elements will be the contour levels.
Each component of this list
will contain an
x
and
y
component suitable for plotting
with
lines
.
plotit
is
TRUE
.
The
triangles
argument selects which of two algorithms is used to create the
contours. The triangle method is more wiggly but will tend to round sharp
corners. The triangle method is somewhat slower, and will create a return
value (when
save
is
TRUE
) that is approximately twice as large.
Each rectangular cell of 4 numbers is contoured independently.
If
triangles
is
FALSE
(the default), contour segments will connect the
edges of the cell crossing the contour level.
At saddle point cells (all 4 edges cross a contour level),
we use the triangle method to select which edges to connect.
If
triangles
is
TRUE
, then
the cell is broken up into 4 triangles meeting at the center
and the
z
value at the center is set to be the average of
the (non-missing) corner values. Then we fit a plane to each
triangle and contour that with straight line segments.
(Triangles with missing values at the corners are ignored.)
Older versions of S-PLUS contained a different
contour
function,
now called
contour.old
.
cont.lines <- contour(x, y, z, save=T) plot(x, y, type="n") for (j in seq(along=cont.lines)) if (length(cont.lines[[j]]$x)) lines(cont.lines[[j]]) rx <- range(ozone.xy$x) ry <- range(ozone.xy$y) i <- interp(ozone.xy$x, ozone.xy$y, ozone.median) #interp creates a matrix of interpolated points, z, for # an increasing, evenly spaced sequence of points # over the range of the input x and y usa(xlim=rx, ylim=ry, lty=2, col=2) contour(i, add=T, labex=0) text(ozone.xy, ozone.median) title(main="Median Ozone in the North East")