persp(x, y, z, xlab = "X", ylab = "Y", zlab = "Z", axes = T,
box = T, eye = <<see below>>, zlim = <<see below>>, ar = 1)
z
is evaluated.
The values should be in sorted order; 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 (
NAs) 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.
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
persp.
x,y,z coordinates for the viewpoint.
The default is
c(-6, -8, 5) times the range of the
x,
y, and
z values.
range(z, na.rm=T). This range will be expanded to round
numbers. The values in the input matrix
z will be truncated
to the z axis limits.
x,y grid,
i.e.,
(xmax-xmin)/(ymax-ymin)" .
persp
assumes that the grid vectors
x and
y are increasing and
evenly spaced. If this is not true, suppress the axes with
axes=F
or use
par commands to customize the axes.
x.
y.
z.
Use
persp.setup to change the color, line width and line type of
the perspective lines.
Use the
perspp function to add information to a perspective
plot.
For some plots (including the case where
mfrow or
mfcol is bigger
than
c(2,2)) parts of the axes are cut off. You can solve this problem
either by putting up fewer figures on the page, changing the perspective
angle with the
eye argument, or by expanding the margin in which the cut
off occurs.
Lines with an endpoint outside the plot may not be drawn.
#Example 1, a polynomial
poly1 <-function(x, y){
x^2 + x * y + y^2 }
y <- x <- seq(-25, 25, length = 50)
persp(x,y, outer(x,y, FUN = poly1))
#Example 2, data at geographic points
i <- interp(ozone.xy$x,ozone.xy$y,ozone.median)
persp(i, xlab = "Longitude", ylab = "Latitude", zlab = "Ozone")
title(main = "Median Ozone Concentrations in the North East")
#Example 3, first argument is a matrix
persp(switzerland)
#Example 4, a smooth surface
int.ak <- interp(akima.x, akima.y, akima.z)
r.ak <- sapply(int.ak, function(x) diff(range(x,na.rm = T)))
par(mfrow = c(2,2), oma = c(0,0,5,0))
persp(int.ak)
persp(int.ak, eye = c(6,-8,5)*r.ak)
persp(int.ak, eye = c(6,8,5)*r.ak)
persp(int.ak, eye = c(-6,8,5)*r.ak)
mtext(outer = T, side = 3, line = 2, "WAVEFORM DISTORTION",
cex = 1.5)
par(mfrow = c(1,1))
persp(int.ak, eye = c(6,8,5)*r.ak)
title(main = "WAVEFORM DISTORTION")