I tried using expression(), which works with noraml plots, but my attempt below fails: any ideas?
I want to write: µg CO2 (subscript 2) – C m-2 (superscript -2) h-1 (supercript -1)
works perfectly:
plot(CO2~water_content, data=gases, ylab = expression(paste("µg ", CO[2], " - C ", m^-2, " ", h^-1, sep="")))
fails:
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=""))
Many thanks!
Subscripts and SuperscriptsTo indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets. In LaTeX equations, a single caret indicates the superscript.
You can use bquote when working with subscripted variables. Say, nIter <- 2 , then plot(1, 1, main = bquote(title[. (nIter)])) is exactly what you need (taken from the R-help mailing list).
your command fails, because the syntax is wrong
qplot(..) ... + ylab = expression(...)
you need something like '+ ylab(...)'
for example like this:
data(diamonds)
qplot(carat, depth, data=diamonds, facets = cut~color, geom='boxplot') +
ylab(expression(paste("µg ", CO[2], " - C ", m^-2, " ", h^-1, sep="")))
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