I need to achieve superscript in an axis label within ggplot2, similiar to this question: Superscript and subscript axis labels in ggplot2
However, I will need to write something like this: Ca^2+. This seems not to work with this approach, even if I put the exponent in { } with the bquote command. I tried to read through help("plotmath") but couldn't find an example for my case. I tried escaping the + with \+ and ++ but was not successful.
Edit: I would like to not use any additional packages.
Try to put the superscript as a literal, between quotes.
g <- ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot()
g + xlab(bquote('Superscript as a literal' ~~ Ca^'2+'))

Using the example you provided, this works
library(ggplot2)
qplot(uptake, data = CO2) +
xlab(bquote('Assimilation ('*mu~ 'mol' ~Ca^{"2+"} ~ m^-2~s^-1*')'))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With