Setting fonts for annotations and titles

For most data analysis, we can just use the default fonts for titles. However, sometimes, we might want to choose different fonts for presentation and publication purposes. Selecting fonts can be tricky, as this depends on the operating system and the graphics device. We will see some simple ways to choose fonts in this recipe.

Getting ready

All you need to try out in this recipe is to run R and type the recipe in the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.

How to do it...

The font family and face can be set with the par() command:

par(family="serif",font=2)

How it works...

A font is specified in two parts: a font family (such as Helvetica or Arial) ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.