trees dataset has three quantitative variables. We looked at the distribution of one of them,
Volume, in a strip chart and the relationship of two of them,
Girth, in a scatter plot. It is possible to visualize all three at once in an extension of the scatter plot, a graph commonly called a 3D scatter plot. Several packages have functions to create 3D scatter plots, including
car, and probably others.
In this section, the
scatterplot3d package is emphasized because its syntax is very much like that of the
plot() function in base R. It is also relatively easy to work with and quite versatile. Finally, many of the tricks that you can use to make 3D plots comprehensible are easily demonstrated with this package. A couple of other functions will also be introduced and compared.
scatterplot3d() function has a basic syntax of either:
scatterplot3d(x, optional arguments)
x is a data frame or matrix,
scatterplot3d(x, y, z, optional arguments)
z are vectors.
Although the first option is usually more convenient, the second is often preferable because it gives you the ability to decide upon the order of the variables or to select a subset of variables. Variable
x is plotted on the horizontal axis,
y on the diagonal axis, and
z on the vertical axis. In the example script that follows,
# script for Figure 17-1 library(scatterplot3d) ...