Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

ggplot2

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

like image 793
Amateur Avatar asked Feb 13 '12 23:02

Amateur


3 Answers

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="")))
like image 137
Vincent Zoonekynd Avatar answered Nov 11 '22 07:11

Vincent Zoonekynd


Try this:

 qplot(0, ylab = ~ "Surface area concentration ( " * mu * m^2 / m^3 * ")")
like image 32
G. Grothendieck Avatar answered Nov 11 '22 06:11

G. Grothendieck


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))
like image 1
cbeleites unhappy with SX Avatar answered Nov 11 '22 05:11

cbeleites unhappy with SX