我正在尝试在 ggplot2 中用表情符号绘制一个情节。我想要的是显示表情符号而不是标签或像 geom 一样显示。Stack 中的这个问题与我的问题非常相似,但它也没有解决它,答案非常手动,我需要自动进行(我的真实数据框有 3000 行)。
只是为了在下面的图中澄清,我想显示表情符号而不是文本标签或条形图。但似乎不可能。
在尝试了不同的解决方案后,我堆积如山,所以任何帮助将不胜感激。我阅读了不同的方式来面对这个问题,比如这里、这里、这里。
我最后一次尝试是这样的:
mult_format <- function() {
function(x) emo::ji(x)
}
ggplot(foo, aes(name_emoji, n)) +
geom_bar(stat = "identity") +
coord_flip() +
scale_y_continuous(labels = mult_format())
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我的数据看起来像这样,name_emoji 来自emo 包,我也可以将其更改为字节:
name_emoji n emoji
<chr> <int> <chr>
1 closed book 1 "\U0001f4d5"
2 confused face 7 "\U0001f615"
3 dizzy 20 "\U0001f4ab"
4 face with tears of joy 1 "\U0001f602"
5 flexed biceps 1 "\U0001f4aa"
6 light …Run Code Online (Sandbox Code Playgroud)