ggplot2 3D Bar Plot

As mentioned in comments, 3D plots usually aren’t a good choice (when other options are available) since they tend to give a distorted/obscured view of data.

That said, here’s how you can plot your data as desired with latticeExtra:

d <- read.table(text=" x   y     z
t1   5   high
t1   2   low
t1   4   med
t2   8   high
t2   1   low
t2   3   med
t3  50   high
t3  12   med
t3  35   low", header=TRUE)

library(latticeExtra)

cloud(y~x+z, d, panel.3d.cloud=panel.3dbars, col.facet="grey", 
      xbase=0.4, ybase=0.4, scales=list(arrows=FALSE, col=1), 
      par.settings = list(axis.line = list(col = "transparent")))

enter image description here

Leave a Comment