2016-03-08 100 views
0

有没有办法在R中重现下面的图?R中的2D单纯形的3d图

enter image description here

编辑

这是我能在plotly与基础R persp()plot_ly做。也有点难看。

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 ...在这里获得matplotlib图: http://blog.bogatron.net/blog/2014/02/02/visualizing-dirichlet-distributions/

+2

也许包RGL? – MLavoie

+0

rgl是个好主意。我苦苦挣扎着“错误加载与Mac OS X的rgl包”在此刻:http://stackoverflow.com/questions/9878693/error-in-loading-rgl-package-with-mac-os-x – Chris

+0

尝试安装/更新XQuartz。尽可能地尝试用3d表面进行渲染。 – Jav

回答

2

使用基地persp RI能远远得到这个:

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") 

但我无法弄清楚如何做几件事,包括greek symbols on axes

如果有任何persp专家想要完成这项工作,我将其转变为维基。

2

这是难看一点/还没有完成,但至少说明在获得希腊标签的一种方式。

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]))