| plot3d {R.basic} | R Documentation |
Method for plotting data in three dimensions.
plot3d(x=seq(0, 1, len=nrow(z)), y=seq(0, 1, len=ncol(z)), z, xlim=range(x), ylim=range(y), zlim=range(z, na.rm=TRUE), xlab=NULL, ylab=NULL, zlab=NULL, main=NULL, sub=NULL, col=NULL, theta=0, phi=15, r=sqrt(3), d=1, scale=TRUE, expand=1, border=NULL, box=TRUE, axes=TRUE, nticks=5, ticktype="simple", depthOrder=TRUE, ...)
x |
the coordinates of points in the plot. Alternatively, a single plotting structure, function or any R object with a plot method can be provided. |
y |
the y coordinates of points in the plot, optional if
x is an appropriate structure. |
z |
the z coordinates of points in the plot, optional if
x is an appropriate structure. |
xlim, ylim, zlim |
the ranges to be encompassed by the x, y and z axes. The plot is produced so that the rectangular volume defined by these limits is visible. |
xlab, ylab, zlab |
the title for the x, y and z axis. These must the character strings; expressions are not accepted. |
main |
an overall title for the plot. |
sub |
the subtitle for the plot. |
col |
the color of the data points. |
theta, phi |
angles defining the viewing direction. theta gives
the azimuthal direction and phi the colatitude. Default values are
theta=0 and phi=15. |
r |
the distance of the eyepoint from the centre of the plotting
box. Default value is sqrt(3). |
d |
a value which can be used to vary the strength of the
perspective transformation. Values of d greater than 1 will
lessen the perspective effect and values less and 1 will exaggerate
it. Default value is 1. |
scale |
before viewing the x, y and z coordinates of the points
defining the surface are transformed to the interval [0,1]. If scale
is TRUE the x, y and z coordinates are transformed separately.
If scale is FALSE the coordinates are scaled so that aspect
ratios are retained. This is useful for rendering things like DEM
information. Default value is TRUE. |
expand |
a expansion factor applied to the z coordinates. Often
used with 0 < expand < 1 to shrink the plotting box in the
z direction. Default value is 1. |
border |
the color of the line drawn around the surface facets.
A value of NA will disable the drawing of borders. This is
sometimes useful when the surface is shaded.
If NULL, will use the default foreground color as defined by
the graphical parameters par.
Default value is NULL. |
box |
should the bounding box for the surface be displayed.
Default value is TRUE. |
axes |
should ticks and labels be added to the box.
If FALSE no ticks or labels are drawn.
Default value is TRUE. |
ticktype |
If "simple" the method draws just an arrow
parallel to the axis to indicate direction of increase.
If "detailed" it draws normal ticks as per 2D plots.
Default value is "simple". |
nticks |
the (approximate) number of tick marks to draw on the
axes. Has no effect if ticktype is "simple".
Default value is 5. |
depthOrder |
If TRUE, the data points are plotted
back-to-from relative to the view plane, otherwise they are plotted
in the order they occur in the data. |
... |
Comma-separated list of things to be displayed. |
Internally plot3d() is based on the persp()
function, which in fact returns a transformation matrix.
Henrik Bengtsson, http://www.braju.com/R/
For adding points to a 3D plot see points3d.
For adding lines to a 3D plot see lines3d.
For adding text to a 3D plot see text3d.
For adding polygons to a 3D plot see polygon3d.
For adding stems to a 3D plot see stem3d.
See also persp.
Package scatterplot3d by Uwe Ligges.
For detail about the graphical parameter arguments, see
par.
# Simulate some (x,y,z) data
n <- 20000
x <- runif(n, 0, 2*pi)
y <- runif(n, 0, 2*pi)
z <- sin(x) * cos(y)
zeroone <- function(x) {
x.r <- range(x, na.rm=TRUE)
(x - x.r[1])/(x.r[2]-x.r[1])
}
h <- zeroone(z)
s <- zeroone(x)
v <- zeroone(y)
col <- hsv(h=h, s=1, v=1)
plot3d(x,y,z, phi=30, theta=30, pch=".", col=col)
omega <- seq(0, 6*pi, length.out=500)
x <- sin(omega); y <- cos(omega)
plot3d(x,y,omega, pch=176, col=hsv(omega/max(omega), 1,1))