【问题标题】:Putting log symbols in ggplot2 text将日志符号放入 ggplot2 文本中
【发布时间】:2018-02-21 23:40:56
【问题描述】:

如何在 ggplot 文本中插入日志符号?

这些是我的尝试:

myLabel = c("log_a b","log{a}")

ggplot(
    data=data.frame(x=0,y=0)
  ) + geom_point(
    aes(x=x,y=y)
  ) + annotate(
    'text', 
    x = 0, y = 0, 
    parse = TRUE,size=10,
    label = myLabel[2])  # here

注意:以上摘自this帖子

【问题讨论】:

  • 您到底要添加什么符号? (对不起,不是数学家!)
  • 您指的是哪个符号(即希腊字母或其他)?在我所知道的所有学术领域中,ln 或 log(在拉丁字母中)代表自然对数。

标签: r ggplot2 formatting


【解决方案1】:

你的意思是这样的吗?

ggplot(data.frame(x = seq(1:10), y = seq(1:10), label = "log[10]"), aes(x, y, label = label)) +
    geom_text(parse = T) +
    annotate("text", x = 1, y = 5, label = "2^log[2]", parse = T)

有关plotmath 中的数学表达式列表,请参阅this link

【讨论】:

    猜你喜欢
    • 2018-05-02
    • 1970-01-01
    • 2010-12-17
    • 1970-01-01
    • 2016-04-29
    • 2015-09-06
    • 1970-01-01
    • 2023-03-25
    • 2023-03-31
    相关资源
    最近更新 更多