问题描述
我正尝试在我的y轴标签上添加化学符号和单位,但是由于某种原因,当我添加上标减号时,也会将带括号的单位也放入上标....我是否应该在上面加上减号放在一些括号中?任何帮助将不胜感激.
I am trying to add chemical notation and units to my y-axis label, but for some reason when I add a superscript minus sign, it throws my bracketed units into superscript too.... should I be putting the minus sign into some brackets? Any help would be appreciated.
我只是想弄清楚它是硝酸盐符号-所以3出现在下标中,而减号是上标,我设法做到了,我只是无法将其从上标中剔除.
Just to clarify it is the Nitrate symbol - so the 3 is in subscript and the minus sign is superscript, which I managed to do, I just cannot get it out of superscript.
以下是一些数据:
dat<-as.data.frame(matrix(runif(100), 2,10))
names(dat) <- LETTERS[1:2]
library(ggplot2)
P1 <- ggplot(dat, aes(A,B)) +
geom_point()
P1 <- P1 + labs(y=expression(rho*"NO"[3]^- ~(µmol ~L^-1 ~d^-1)))
推荐答案
由于-
符号后没有数字,因此需要将其引用并放在大括号中
As there is no number following the -
symbol you need quote it and put it in curly brackets
P1 + labs(y=expression(rho*"NO"[3]^{"-"} ~(µmol ~L^-1 ~d^-1)))
这篇关于ggplot标签添加上标,如何从上标出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!