r - 将日志符号放入 ggplot2 文本中

标签 r ggplot2 formatting

如何在 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发布

最佳答案

你的意思是这样吗?

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)

enter image description here

参见this link获取 plotmath 中的数学表达式列表。

关于r - 将日志符号放入 ggplot2 文本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48917340/

相关文章:

r - ggplot2中的线宽(大小)是如何定义的?

python - 使用 Pandas DataFrame Styler 格式化日期时间索引,只显示时间部分

html - 在 div/iframe/image 周围环绕文本

properties - JavaFX 8 绑定(bind)数字格式

r - 如何根据R中坐标之间的距离将数据点分组在一起?

r - 矩阵的每个连续行向右循环 1 个位置

R:为什么 boxplot(x,log ="y") 与 boxplot(log(x)) 不同?

r - ggplot2: annotation_custom 给出一个空层

r - ggplot2 : Aesthetics must either be length one, 或相同长度的几张图

r - ggplot 中的条形图,每组条数不同