How can I plot cubes in R?

Can you please help me understand this methodology called "Bambachian Mega Guild" (Bambach et al., 2007). This methodology tries to locate the Tiering, Feeding and Motility variables of the species according to the percentage of their appearance within a 3D cube. I want to try to understand which package to use to make this plot in R, since the truth is that I am not very clear about how to design these cubes as you can see them in the attached image.

Bush, A. M., Bambach, R. K., & Daley, G. M. (2007). Changes in theoretical ecospace utilization in marine fossil assemblages between the mid-Paleozoic and late Cenozoic. Paleobiology, 33(01), 76–97. doi:10.1666/06013.1

enter image description here

1 answer

  • answered 2021-01-11 13:35 user2554330

    I haven't seen that kind of display from an existing R package (though it might exist). You could probably build it up yourself using the rgl package, e.g. this code

    library(rgl)
    locations <- cbind(x = rep(1:6, 36), y = rep(rep(1:6, 6), each = 6), 
                       z = rep(1:6, each = 36))
    colors <- sample(c("white", "blue", "red"), 216, 
                     rep=TRUE, prob=c(0.9, 0.1, 0.1))
    for (i in 1:216)
      shade3d(translate3d(cube3d(scaleMatrix(0.3, 0.3, 0.3), col = colors[i]), 
                          x=locations[i,1], y = locations[i, 2], z = locations[i, 3]))
    

    produces this figure

    screenshot

    However, that would be a lot of work. If you wanted to display the data, but not necessarily in a fake 3D plot, the mosaicplot() in the base graphics package might be able to do what you want, depending on what your data is like. Including some sample data in your question (using dput(<your data>)) would make it easier to answer.