如何在R中的标绘标签中写出每立方米的微米平方

时间:2012-02-13 23:25:56

标签: r ggplot2

我想在ggplot中的情节label中写微米平方/立方米,当我添加m ^ 2时出现错误。第一个表达式还可以,但它缺少^ 2。我尝试添加m ^ 2不起作用,因为我没有看到上标。

  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="")))

  3. 谢谢

3 个答案:

答案 0 :(得分:8)

这只是一个引用问题:

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

答案 1 :(得分:6)

试试这个:

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

答案 2 :(得分:1)

或者,甚至更短:

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