persp(x, y, z, xlab = "X", ylab = "Y", zlab = "Z", axes = T, box = T, eye = <<see below>>, zlim = <<see below>>, ar = 1)
The first argument may be a list with components x, y, and z. In particular, the result of interp is suitable.
If the first argument is a matrix, it is assumed to be the 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.
Graphical parameters may also be supplied as arguments to this function (see par ).
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.
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")