Using Google Fonts with Plots in R
The R Project is free software for statistical computing

There is a plethora of fonts out there to make your plots more appealing to the eye. Thanks to the package showtext, you are able to use fonts from Google Fonts on your plots.

Remember that showtext does not work on RStudioGD. This implies that custom fonts will not show on your RStudio IDE. Instead, you can save the plot with the desired fonts in different supported formats.

Here is an example on how to use the font Lobster in a plot saved as a PNG image.

# load libraries
library(ggplot2)
library(showtext)

# add the font and turn showtext on automatically when using graphics
font_add_google('lobster')
showtext_auto()

# create plot with iris data
pp <-
  ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
	geom_point(shape=1) +
	ggtitle('Here, some Iris data') +
	theme(text = element_text(family = 'lobster')) # set the font for plot

# call the plot
pp

# save the plot
ggsave("showtext-example.png", plot = pp, width = 7, height = 4, dpi = 96)

As mentioned, prompting the plot to appear in RStudio will show the default font.

2021-02-12-google-font-r-img01

Yet, the saved file will have the desired outcome.

2021-02-12-google-font-r-img02

References:

Fonts not loading in showtext font_add_google

Using Google Fonts with Plots in R
Older post

Top 10: Books Read in 2020

A few thoughts on what I considered were the best books I read/listened to in 2020.

Newer post

Challenge November 2020: My First 100k Run

Running alongside the Mauerweg on a cold November day

Using Google Fonts with Plots in R