繁体   English   中英

r中的情节标题下标

[英]Subscript in plot title in r

我想补充标题“1999年至2008年美国PM2.5的排放”,该标题使用r中的基础绘图功能。 在那,我希望2.5成为PM的下标。 如果PM2.5恰好位于字符串的末尾,我没有任何问题:

barplot(height = total.emissions$Emissions, names.arg=total.emissions$year,  
        xlab="Year", ylab= " Amount of emitted in tonsPM"2.5 ,   
        main = "Emissions from in the United States from 1999 to 2008PM"[2.5] )

但如果它在字符串的中间,我就不能这样做。 如果我把它分成两部分,如下:

barplot(height = total.emissions$Emissions, names.arg=total.emissions$year,  
        xlab="Year", ylab= " Amount of PM_[2.5] emitted in tons",   
        main = expression("Emissions from PM"[2.5] "in the United States from 1999 to 2008"))

由于方括号,我收到错误说出意外的符号。

尝试使用paste函数进行expression (有关详细信息,请参阅?plotmath ),例如:

plot(0, main = expression(paste("Emissions from ", PM[2.5], " in the United States from 1999 to 2008")))

暂无
暂无

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

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