# Constructing a 3D scatter plot

A 3D scatter plot is a great tool for visualizing multivariate data. Adding a third dimension to the existing plot helps in revealing information and portraying data from a newer angle. Even higher dimensions, such as the fourth and fifth, can be visualized by making use of color and shape attributes. We will implement this recipe using the `plot3D`

package. The following screenshot shows a 3D scatter plot:

## Getting ready

To implement a scatter plot in 3D, we will need to install and load the plot3D package in R. The manual for the package is available on the CRAN website http://cran.r-project.org/web/packages/plot3D/plot3D.pdf.

## How to do it…

The package is installed and loaded in R using the `install.packages()`

and `library()`

functions respectively in R.

install.packages("plot3D") library(plot3D)

The data used in generating the scatter plot is part of the book titled *An Introduction to Statistical Learning*, *Gareth James*, *Daniela Witten*, *Trevor Hastie...*