[英]Subscript and super script in R plot
How to write the following expression in R plot function: 如何在R plot函数中编写以下表达式:
$$Acceleration (ms^{-2})$$ $$加速度(ms ^ { - 2})$$
I have tried to use expression()
, but it does not work for text and equations together. 我曾尝试使用
expression()
,但它不适用于文本和方程式。
[Updated] [更新]
Usually, it does not work in R Surf 3D plot. 通常,它在R Surf 3D图中不起作用。 Here is an example:
这是一个例子:
pm <- par("mflow")
pmar <- par("mar")
par(mar=c(2,2,2,2))
par(mflow=c(1,1))
velocity <- seq(0,35,length.out=50)
acceleration <- seq(-2,3,length.out=50)
M <- mesh(velocity,acceleration)
alpha <- M$x
beta <- M$y
x<- 1* alpha
y <- 1*beta
z <- (1300*alpha*beta+0.5*1.20*1.97*0.33*alpha*alpha*alpha +
1300*9.8*0.018*alpha)/(1000*.9*.97)
surf3D(x,y,z,colkey=FALSE,colvar=z,drap=TRUE, shade = 0.0,
lighting = TRUE,bty="b2",theta=40, sub="subtitle",
xlab = expression(Velocity~(ms^{-1})),
ylab = expression(Acceleration~(ms^{-2})),
zlab = expression(Energy consumption~(mAhs^{-1})),
xlim = c(0, 35), ylim=c(-2, 3), ticktype="detailed",
facets=FALSE,phi=10,cex.lab=1.5,font.lab=2,lwd=1.5)
尝试expression(Acceleration~(ms^{-2}))
如下所示:
plot(1:10, 1:10, xlab = expression(Acceleration~(ms^{-2})))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.