A simple 3D histogram

We have studied histograms in Chapter, A Simple Guide to R. We will try to plot a 3D histogram in this recipe. The applications of 3D histograms are limited, but they are a great tool for displaying multiple variables in a plot. In order to construct a 3D histogram, as shown in the following screenshot, we will use the plot3d package available in R.

A simple 3D histogram

Getting ready

To plot a histogram in 3D, we will use the plot3D package available in R.

How to do it…

We will install as well as load the plot3D package in R using the install.packages() and library() functions, respectively.

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

We will now generate ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.