In this recipe, we will learn how to create three-dimensional scatter plots that can be very useful when we want to explore the relationships between more than two variables at a time.
We need to install and load the scatterplot3d
package in order to run this recipe:
install.packages("scatterplot3d") library(scatterplot3d)
Let's create the simplest default three-dimensional-scatter plot with our mtcars
dataset:
scatterplot3d(x=mtcars$wt, y=mtcars$disp, z=mtcars$mpg)