简体   繁体   English

R中2d单纯形的3d图

[英]3d plot of 2d simplex in R

Is there a way to reproduce the following plot in R? 有没有办法在R中重现以下图?

在此处输入图片说明

EDIT 编辑

This is what I could do with persp() in base R and plot_ly in plotly. 这就是我可以做persp()的基础R和plot_ly在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/ 顺便说一句... matplotlib图在这里获得: http : //blog.bogatron.net/blog/2014/02/02/visualizing-dirichlet-distributions/

Using persp in base RI was able to get this far: 在基本RI中使用persp可以达到以下目标:

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. persp它变成一个Wiki,以防persp有专业人士想完成这项工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM