GuangchuangYu / emojifont

:lollipop:Emoji and fontawesom in both base and ggplot2 graphics
https://guangchuangyu.github.io/emojifont/
67 stars 22 forks source link

ggplot example not working in rMarkdown #21

Closed ndsubison2178 closed 5 years ago

ndsubison2178 commented 5 years ago

This example

library(emojifont)
dd=data.frame(x=emoji(c("satisfied", "disapointed")), y=c(50, 10))
emoji_text=element_text(family="OpenSansEmoji", size=20)
ggplot(dd, aes(x, y)) + geom_bar(stat='identity', aes(fill=x)) + 
     ggtitle(paste(emoji(c("+1", "-1")), collapse=" "))+ 
        theme(axis.text.x = emoji_text, legend.text=emoji_text, title=emoji_text) + 
            xlab(NULL)+ylab(NULL)

Works in regular r or rstudio desktop

When I take this to rMarkdown it does not work. I am using the rmarkdown template https://raw.githubusercontent.com/GuangchuangYu/emojifont/master/vignettes/emojifont.Rmd

and calling ```{r fig.showtext=TRUE}

GuangchuangYu commented 5 years ago

you need to do :

load.emojifont("OpenSansEmoji.ttf")

before ggplot.