【问题标题】:Overwrite ggplot axis labels with Latex expressions用 Latex 表达式覆盖 ggplot 轴标签
【发布时间】:2021-08-03 22:55:25
【问题描述】:

如何使用通过latex2exp package 评估/打印的乳胶表达式覆盖轴文本(连接到 tix 的文本,而不是轴标题)?

重命名轴文本的常规方法不起作用:

MWE

df <- data.frame(x=c("a","b"), y=c(1,2))
ggplot(df, aes(x, y))+
  geom_point()+
  scale_x_discrete(labels=c(TeX("$Test^{89}$"), TeX("$Oh_{i,j}^{99}$")))

【问题讨论】:

    标签: r ggplot2 latex axis-labels


    【解决方案1】:

    刚刚发现 - 它与this question 有关。基本上,您需要将unname() 包裹起来。

    df <- data.frame(x=c("a","b"), y=c(1,2))
    ggplot(df, aes(x, y))+
      geom_point()+
      scale_x_discrete(labels=unname(TeX(
        c("$Test^{89}$","$Oh_{i,j}^{99}$"))))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      相关资源
      最近更新 更多