Bakaburg
Bakaburg

Reputation: 3311

Can't use font awesome in R

I'm trying to use font awesome icons in ggplot, but I can't have them showing. In the plot they just are not present while in console they print as missing character. I tried to use them this way:

> library(emojifont)
> load.fontawesome()
> fontawesome('fa-check-circle')
[1] " "

In ggplot I tried:

geom_text(size = 7, nudge_y = .1, color = 'steelblue', family='fontawesome-webfont')

but it displays nothing.

Font awesome is properly installed on my computer, and it works in microsoft word or other text editors. I'm on MacOS High Sierra.

Thanks

Upvotes: 5

Views: 3980

Answers (1)

ekstroem
ekstroem

Reputation: 6151

Here is a solution that might work for you

library(ggplot2)
library(emojifont)
load.fontawesome()

## Generate some data
DF <- data.frame(x=1:5, y=1:5)
ggplot(DF, aes(x=x, y=y)) + 
     geom_text(label=fontawesome('fa-check-circle'), family='fontawesome-webfont')

Here is a slightly more fun version using version 4.7 icons (fa-meetup)

ggplot(DF, aes(x=x, y=y)) + 
     geom_text(label=fontawesome(c('fa-check-circle', 'fa-linux', 'fa-meetup', 'fa-github', 'fa-eur')), 
               family='fontawesome-webfont', 
               size=seq(6, 14, 2))

Upvotes: 1

Related Questions