I am trying to use ggplot2
to plot some graphs with emojis shown as labels using the emo
package. I've learned it from this post, but it's simply not working.
I have tried the emojifont
package before, but it's a font type that renders emojis in black and white and it requires opening a new graphics device using e.g. quartz()
.
To go around the color problem, Tino has suggested (refer to the post above) using the gridSVG
package, i.e. after creating a new graphics device and plotting with emojifont
, save the graph ps = grid.export("emoji.svg", addClass=T)
on local disk as a .svg
file that renders emojis in a colorful style.
I would really appreciate a solution that (a) gives colorful emojis and (b) showing the graph directly, which is compatible with routine ggplot
use cases.
library(ggplot2)
library(emo)
names = c("smile","school","office","blush","smirk","heart_eyes")
n = length(names):1
e = sapply(names, emo::ji)
dat = data.frame(emoji_name = names, n = n, emoji = e, stringsAsFactors = F)
ggplot(data=dat, aes(emoji_name, n)) +
geom_bar(stat = "identity") +
scale_x_discrete(breaks = dat$emoji_name, labels = dat$emoji) +
coord_flip()
My R version is
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12
)
was a typo. Removing it still does not fix things. I am using a Mac OS; I was wondering if the problem is OS-dependent. – Gonzalesggplot2
version 3.0.0 – Jansson