我最近发现可以在ggplot的注释文本中添加希腊字母和其他符号。我正在尝试向我的文本添加箭头(向上和向下),我似乎找不到正确的数字代码。我尝试搜索但无法在线查找代码列表。语法类似于标签:
label="'test text ' * symbol('\\205')"
\ 142给出一个beta符号,\ 154给出一个gamma符号。谁知道这段代码是如何工作的?谢谢!
答案 0 :(得分:6)
以下作品:
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以下是结果图: