Is there a way to reproduce the following plot in R?
EDIT
This is what I could do with persp()
in base R and plot_ly
in plotly. Also a bit ugly.
x <- seq(0,1,0.01)
y <- seq(0,1,0.01)
f <- function(x,y){ z <- -x - y + 1 }
z <- outer(x,y,f)
z <- ifelse(z<0,NA,z)
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")
plot_ly(x=x,y=y,z=z,type="surface") %>% layout(xaxis=list(range=c(0,1)), yaxis=list(range=c(0,1)), zaxis=list(range=c(0,1)))
BTW...the matplotlib plots were obtained here: http://blog.bogatron.net/blog/2014/02/02/visualizing-dirichlet-distributions/
Using persp
in base RI was able to get this far:
persp(0:1, 0:1,
matrix(c(1,0,0,NA), nrow=2),
col="green", theta=60,
xlab= "theta_1",
ylab = "theta_2",
zlab="theata_3")
But I could not figure out how to do a few things, including greek symbols on axes .
I am turning this into a wiki in case any persp
experts out there want to finish the job.
This is a little ugly/still incomplete but at least shows one way to get Greek labels in.
pp <- persp(0:1, 0:1,
matrix(c(2,0,0,NA), nrow=2),
col="green", theta=60,
xlab= "",
ylab ="",
zlab="",
ticktype="detailed",
nticks=1)
text(trans3d(0.5,-0.1,-0.1,pp),labels=expression(theta[1]))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.