4

I am trying to create a 3D(4D?) Dirichlet probability density function plot similar to one of these (from Wikipedia):

enter image description here

My data consists of 3 columns and 100000 rows where each row sums to 1 obtained from the rdirichlet function. I can create a heatmap version using DirichletReg, which is roughly equivalent to the bottom right plot from the Wikipedia plots above as follows:

library(gtools)
library(DirichletReg)

dat <- rdirichlet(100000, alpha = c(10,1,10))
plot(DR_data(dat), a2d = list(colored = TRUE, c.grid = FALSE, col.scheme = c("entropy")))

enter image description here

Or I can create a uniform heatmap version similar to the top left Wiki plot as follows:

dat2 <- rdirichlet(100000, alpha = c(1,1,1))
plot(DR_data(dat2), a2d = list(colored = TRUE, c.grid = FALSE, col.scheme = c("entropy")))

enter image description here

My question: Instead of a heatmap is it possible to make the ternary plot 3D like the wiki plots? I have tried to do this using plotly and plot3d packages but haven't been able to come close. Any help would be much appreciated.

flee
  • 1,253
  • 3
  • 17
  • 34
  • 1
    Haven't been able to find a package that does this out of the box. But I did make a Matlab plot3d clone in R. See this answer: A: How to create 3D - MATLAB style - surface plots in R: https://stackoverflow.com/questions/20549540/how-to-create-3d-matlab-style-surface-plots-in-r/20553451?s=1|60.5445#20553451 – IRTFM Mar 17 '18 at 19:00

0 Answers0