Description Usage Arguments Author(s) See Also Examples
Adding data points to a three dimensional plot previously created by
plot3d()
or persp()
.
Note that adding data points to a three dimensional plot will violate
the depth order of the data points; data points that should be in the
back, maybe hidden by other data points, might be plotted on top of
the latter instead. Normally this behavior is not wanted and it is
preferred to plot all data points at once using plot3d()
,
which preserved the depth order.
1 2 3 4 |
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
|
z |
the z coordinates of points in the plot, optional if
|
persp.matrix |
an 4-by-4 transformation matrix describing how
to project the (x,y,z) points to the drawing canvas as the one
returned by |
cex |
the character expansion of the data points. Default is
|
col |
the color of the data points.
Default value is |
pch |
plotting "character", i.e. symbol to use. For more
information see |
depthOrder |
If |
... |
further arguments accepted by |
Henrik Bengtsson
For creating a 3D plot see plot3d
().
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
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Simulate three groups of (x,y,z) data
n <- 3*1000
gr <- list()
gr[[1]] <- matrix(rnorm(n, mean=c(0,0,1), sd=c(1,1,1)), ncol=3, byrow=TRUE)
gr[[2]] <- matrix(rnorm(n, mean=c(5,4,2), sd=c(1,2,1)), ncol=3, byrow=TRUE)
gr[[3]] <- matrix(rnorm(n, mean=c(2,2,4), sd=c(0.2,0.5,0.8)), ncol=3, byrow=TRUE)
# Calculate the overall limits of the axis
xlim <- ylim <- zlim <- NA
for (k in 1:3) {
gr[[k]] <- as.data.frame(gr[[k]])
colnames(gr[[k]]) <- c("x", "y", "z")
xlim <- range(xlim, gr[[k]][,1], na.rm=TRUE)
ylim <- range(ylim, gr[[k]][,2], na.rm=TRUE)
zlim <- range(zlim, gr[[k]][,3], na.rm=TRUE)
}
# First plot one group using plot3d()...
plot3d(gr[[1]], phi=50, pch=176, col="red", xlim=xlim, ylim=ylim, zlim=zlim,
xlab="x", ylab="y", zlab="z")
# ...and then use points3d() to plot the other groups
for (k in 2:3)
points3d(gr[[k]], pch=176, col=c("blue", "green")[k-1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.