(This article was first published on

**Statistics, R, Graphics and Fun » R Language**, and kindly contributed to R-bloggers)Motivated by the excellent R package `pgfSweave`

, I begin to notice the font families in my graphs when writing Sweave documents. The default font family for PDF graphs is `Helvetica`

, which is, in most cases (I think), inconsistent with the LaTeX font styles. Some common font families are listed in `?postscript`

, and we can take a look at them by:

for (f in c("AvantGarde", "Bookman", "Courier", "Helvetica", "Helvetica-Narrow", "NewCenturySchoolbook", "Palatino", "Times")) { pdf.options(family = f) pdf(paste(f, ".pdf", sep = "")) set.seed(123) plot(rnorm(25), pch = 1:25, xlab = "xlab family", ylab = "ylab font", main = paste("Font Families in R (PDF):", f)) text(13, 0, "Text in the Middle") mtext(sprintf("pdf.options(family = \"%s\")", f), side = 4) dev.off() }

Here is a merged PDF containing the above single PDF files:

It seems that `"Bookman"`

, `"NewCenturySchoolbook"`

, `"Palatino"`

and `"Times"`

can be better choices when using Sweave because they are serif fonts, which are usually more consistent with LaTeX PDF.

## Related Posts

To

**leave a comment**for the author, please follow the link and comment on his blog:**Statistics, R, Graphics and Fun » R Language**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...