【问题标题】:Adding arrow symbols in ggplot text in R在 R 中的 ggplot 文本中添加箭头符号
【发布时间】:2016-06-15 01:38:49
【问题描述】:

我最近发现可以在 ggplot 的注释文本中添加希腊字母和其他符号。我正在尝试在我的文本中添加箭头(向上和向下),但我似乎找不到正确的数字代码。我尝试搜索但无法在线找到代码列表。语法类似于标签下的内容:

label="'test text ' * symbol('\\205')"

\142 给出一个 beta 符号,\154 给出一个 gamma 符号。有人知道这段代码是如何工作的吗?谢谢!

【问题讨论】:

标签: r text ggplot2 symbols arrows


【解决方案1】:

以下作品:

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  geom_smooth(aes(colour = "loess"), method = "loess", se = FALSE) +
  geom_smooth(aes(colour = "lm"), method = "lm", se = FALSE) +
  labs(colour = "Method") +
  annotate("text", x = 3.5, y = 35, label = sprintf('\u2191')) +
  geom_curve(aes(x = 4, y = 30, xend = 3.5, yend = 34), 
             colour = "#FF0000", 
             size=0.5, 
             curvature = -0.2,
             arrow = arrow(length = unit(0.03, "npc"))) +
  geom_label(aes(x = 4, y = 31, label = "Here is the\nUnicode symbol"), 
             hjust = 0, 
             vjust = 0.5, 
             colour = "#FAAB18", 
             fill = "white", 
             label.size = NA, 
             family="Helvetica", 
             size = 6)

here 中箭头的 Unicode

这是结果图:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2016-06-22
    • 2014-02-21
    • 1970-01-01
    相关资源
    最近更新 更多