The showtext
package in R is
designed to make it easy to use custom fonts in R
graphics, including plots created with base R, ggplot2, and
other graphics systems.
This post showcases the key
features of showtext
and provides a set of
graph examples using the package.
{showtext}
The showtext
package in R allows you to easily use
custom fonts in R graphics, including plots created with base R, ggplot2, and
other graphics systems.
It provides a simple interface to use system fonts and web fonts in R plots, making it easy to create publication-quality graphs with custom typography.
✍️ author → Yixuan Qiu
📘 documentation → CRAN
⭐️ more than 500 stars on github
To get started with showtext
, you can install it
directly from CRAN using the install.packages
function:
The showtext
package allows you to use custom fonts in
your R graphics by loading font files and enabling showtext
rendering.
Here’s a basic example:
showtext
can load fonts from various sources, including
system fonts, font files, and Google Fonts.
font_add_google()
: simplifies adding Google Fonts by
fetching and registering fonts directly from the Google Fonts repository
using just the font family name.The showtext_auto()
function enables automatic font
rendering for all graphics devices.
👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥