qplot的ylab中的下标和上标[R]

Mic*_* Ka 5 r ggplot2

我尝试使用表达式(),它与noraml图一起使用,但我的尝试失败了:任何想法?

我想写一下:μgCO2 (下标2) - C m-2 (上标-2) h-1 (上标-1)

完美的工作:

plot(CO2~water_content, data=gases, ylab = expression(paste("µg ", CO[2], " - C ", m^-2, " ", h^-1, sep="")))             
Run Code Online (Sandbox Code Playgroud)

失败:

qplot(factor(vegetation_dummy),CO2,facets=sampling~biochar,geom=c('boxplot'),data=gases_PL)+theme_bw()+xlab('Plants')+ylab = expression(paste("µg ", CO[2], " - C ", m^-2, " ", h^-1, sep=""))
Run Code Online (Sandbox Code Playgroud)

非常感谢!

小智 11

您的命令失败,因为语法错误

qplot(..) ... + ylab = expression(...) 
Run Code Online (Sandbox Code Playgroud)

你需要'+ ylab(...)'之类的东西

例如像这样:

data(diamonds)
qplot(carat, depth, data=diamonds, facets = cut~color, geom='boxplot') + 
ylab(expression(paste("µg ", CO[2], " - C ", m^-2, " ", h^-1, sep="")))
Run Code Online (Sandbox Code Playgroud)