2016-03-08 70 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]))