O'Reilly logo

R Data Visualization Cookbook by Atmajitsinh Gohil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating plots with custom fonts

The main aim of this recipe is to introduce you to installing fonts and how to use them to label plots. We have used xkcd fonts for this recipe to introduce humor in our plots. The fonts look very similar to the XKCD cartoon strip.

Generating plots with custom fonts

Getting ready

To download and generate plots using the xkcd package, we require the sysfonts package.

How to do it…

The install.packages() and library() functions allow us to download the packages as well as load the library in R:

install.packages("sysfonts")
library(sysfonts)

Next, we just copy and paste the following lines of code to the R command window. These lines of code are used to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required