O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a 3D histogram

The three-dimensional histogram function, hist3D(), has the following attributes:

  • z: Values contained within a matrix.
  • x, y: Vectors, where length of x should be equal to nrow(z) and length of y should be equal to ncol(z).
  • colvar: Variable used for the coloring and has the same dimension as z.
  • col: Color palette used for the colvar variable. By default, a red-yellow-blue color scheme.
  • add: Logical variable. If TRUE, adds surfaces to the current plot. If FALSE, starts a new plot.

Let's plot the Death rate of Virgina using a 3D histogram:

data(VADeaths)hist3D(z = VADeaths, scale = FALSE, expand = 0.01, bty = "g", phi = 20, col = "#0085C2", border = "black", shade = 0.2, ltheta = 80, space = 0.3, ticktype = "detailed", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required