【问题标题】:How can I add a subscript to my axis label when using persp3D function in R?在 R 中使用 persp3D 函数时,如何为轴标签添加下标?
【发布时间】:2020-07-10 12:36:10
【问题描述】:

我试图在plot3D 中将我的 z 轴标签定义为 R0,下面是我的代码,我正在为我的zlab 使用表达式,但我得到的结果如下附在此处的图像。

library(plot3D)
lambda <- 1/12
sigma <- 0.4
gamma <- 0.4
beta <- 0.00007
c <-0.0034
m <- (0.08/12)
mu <- 1
f <- function(x,y){(beta*(x*(m+lambda)/((m+c)*(m+lambda)+m*y))*sigma*gamma)/((m+sigma+c)*(m+mu+c))}
x <- seq(0,1000,10)
y <- seq(0,1,0.01)
z <- outer(x,y,f)
persp3D(x=x, y=y, z=z, 
    col.palette = heat.colors, 
    phi = 20, theta = 300, nticks=4,
    zlab=expression('R'[0]), ylab = "k", xlab="A", 
    xlim = c(0, 1000), 
    ylim = c(0, 1), 
    zlim = c(0, 3.5),
    box = TRUE, border = NA, shade = .4,ticktype="detailed",scale= TRUE, expand = 0.5)

【问题讨论】:

标签: r 3d axes subscript plot3d


【解决方案1】:

text3D() 允许表达式显示数学注释。记得将图形参数中的xpd设置为TRUE,否则超出“绘图”区域时文本会被剪掉。

persp3D(..., zlab = "", ...) # blank zlab
par(xpd = TRUE)
text3D(0, 1.4, 1, expression(R[0]), add = T)

【讨论】:

  • 谢谢您,先生。这正好解决了我的问题。谢谢:)
猜你喜欢
  • 1970-01-01
  • 2020-09-14
  • 1970-01-01
  • 1970-01-01
  • 2014-06-29
  • 2020-06-17
  • 2018-10-30
  • 1970-01-01
  • 2018-08-19
相关资源
最近更新 更多