【发布时间】:2017-01-09 14:23:45
【问题描述】:
我只想写Fe2+,上标“2+”。
这行得通(“+2”是上标,但顺序不对):
df <-data.frame(a=seq(1,20),b=seq(1,20))
ggplot(df, aes(x = a, y = b)) + geom_point() +
xlab(expression(Fe^{+2} ~ (mu ~ M)))
这不是:
ggplot(df, aes(x = a, y = b)) + geom_point() +
xlab(expression(Fe^{2+} ~ (mu ~ M)))
显然,{2+} 中“2”之后的“+”运算符需要特殊处理。任何帮助表示赞赏。
或者,如果有人可以解决以下表达式的相同问题,我会很高兴:
ggplot(df, aes(x = a, y = b)) + geom_point() +
xlab(bquote(Fe^2+~' '~'('*mu~'M)'))
【问题讨论】:
-
相关:Minus as an exponent in plotmath (in ggplot2 legend)。因此,
xlab(expression(Fe^{2+phantom()} ~ (mu ~ M)))有效。