Fonts in R plots

A list of fonts is available to the pdf() command, like this:

> names(pdfFonts())
 [1] "serif"                "sans"                 "mono"                
 [4] "AvantGarde"           "Bookman"              "Courier"             
 [7] "Helvetica"            "Helvetica-Narrow"     "NewCenturySchoolbook"
[10] "Palatino"             "Times"                "URWGothic"           
... etc ...

To use when creating a PDF, for example:

> pdf(file="plot.pdf",family="Palatino", pointsize=16, width=16,height=10)

You can use system fonts with cairo_pdf. On Ubuntu (and many other types of Linux, I guess), the family argument takes any font name you see in fc-list.

Alternatively, you can use the extrafont package. This will allow you to use any system font with the regular pdf device.

Tags:

Fonts

Graphics

R