how to write micrometer squared per cubic meter in plot label in R

15,338

Solution 1

That is just a quote problem:

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

Solution 2

Try this:

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

Solution 3

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))
Share:
15,338
Amateur
Author by

Amateur

Updated on June 14, 2022

Comments

  • Amateur
    Amateur over 1 year

    I would like to write micrometer square/cubic meter in my plot label in ggplot and I got an error when I add m^2. The first expression is ok but it's missing the ^2. My attempt to add m^2 did not work because I did not see the superscript.

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

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

    Thank you