【问题标题】:Expression of italics and superscripts in ggplot axis titleggplot 轴标题中斜体和上标的表达
【发布时间】:2017-03-24 10:44:46
【问题描述】:

很抱歉问这个问题,但我似乎无法正确将此表达式包含在 ggplot2 对象的 ylab()xlab() 参数中。它需要阅读:

2q(稀有)”。不过,“2”需要上标。

我曾摆弄过expression()paste(),但这似乎是不可能的。非常感谢任何帮助。

编辑:一些例子:

dat<-as.data.frame(matrix(runif(100), 10,10))
names(dat) <- LETTERS[1:10]

library(ggplot2)
ggplot(dat, aes(A,B)) +
  geom_point()+
  xlab("some title")

【问题讨论】:

  • 请提供一个可重现的例子。
  • 对不起 - 我认为这里没有必要。
  • 你是对的,但它使其他人不必生成数据来修补。

标签: r ggplot2


【解决方案1】:

所有必要的信息都可以在help("plotmath")找到。

ggplot(dat, aes(A,B)) +
  geom_point()+
  xlab(expression({}^2*italic(q)~textstyle(group("(", rarefied, ")"))))

【讨论】:

  • 那不是下标,不是上标吗?
  • 只是好奇:如果我前面的“2”也应该是斜体怎么办? xlab(expression((italic({}^2)*italic(D)) 什么都不做。
  • 有限制。我不认为你可以结合italicscriptstyle。你可能不应该为了可读性。
猜你喜欢
  • 1970-01-01
  • 2020-03-07
  • 1970-01-01
  • 1970-01-01
  • 2021-07-23
  • 2021-02-19
  • 2021-11-23
  • 1970-01-01
  • 2021-08-03
相关资源
最近更新 更多