How to write a square micrometer per cubic meter in the graph label in R

I would like to write a micrometer square / cubic meter in my graph labelin ggplot, and I got an error when I add m ^ 2. The first expression is fine, but it does not contain ^ 2. My attempt to add m ^ 2 did not work because I did not see a superscript.

  • ylab (expression(paste("Surface area concentration (",mu,"m/",m^3,")", sep="")))

  • ylab (expression(paste("Surface area concentration (",mu,",m^2,"/,m^3,")", sep="")))

thank

+5
source share
3 answers

This is just a problem with a quote:

library(ggplot2)
qplot(mpg, wt, data = mtcars) + 
ylab (expression(paste(
  "Surface area concentration (",
  mu, m^2, "/", m^3,
  ")", sep="")))
+5
source

Try the following:

 qplot(0, ylab = ~ "Surface area concentration ( " * mu * m^2 / m^3 * ")")
+6
source

Or, even shorter:

plot(0, ylab = ~ "Surface area concentration" (mu * m^2 / m^3))
plot(0, ylab = Surface~area~concentration (mu * m^2 / m^3))
+1
source

All Articles