The `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, `Height`

and `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 `lattice`

, `scatterplot3d`

, `rgl`

, `plot3D`

, `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.

The `scatterplot3d()`

function has a basic syntax of either:

scatterplot3d(x, optional arguments)

where `x`

is a data frame or matrix,

or:

scatterplot3d(x, y, z, optional arguments)

where `x`

, `y`

, and `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

is plotted on the horizontal axis, *x*

on the diagonal axis, and *y*

on the vertical axis. In the example script that follows, *z*

, *x*

, and *y*

are *z*`Height`

, `Girth`

, and `Volume`

.

# script for Figure 17-1 library(scatterplot3d) ...

Start Free Trial

No credit card required