如何在R plot函数中编写以下表达式:
$$加速(ms ^ { - 2})$$
我曾尝试使用expression()
,但它不能同时用于文本和方程式。
[更新]
通常,它在R Surf 3D图中不起作用。这是一个例子:
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)
答案 0 :(得分:0)
请尝试expression(Acceleration~(ms^{-2}))
,如下所示:
plot(1:10, 1:10, xlab = expression(Acceleration~(ms^{-2})))