R is a great tool to analyze data and build beautiful graphs. However, not ever problem has a straight forward solution. One of those problems is using OpenType fonts in graphs.
After some despair, I found this great How-To: How to use your favorite fonts in R charts. Because it explains a little more than necessary for this problem, here is my final walk-through:
Download Rtools. Be careful to select the correct version for your installation of R. I use R 3.1.2 and Rtools31.
Install the necessary packages:
library(devtools) install_github("Rttf2pt1", "wch") install_github("extrafont", "wch") install_github("Rttf2pt1", "wch", "freetype") install_github("Rttf2pt1", "wch", "freetype2")
Load the fonts:
Look up the name of the font in the results of
If everything worked, now you are ready to use the font for your plots:
png(filename = "out.png", width=7, height=5, units = "in", pointsize = 8, res=300, restoreConsole = TRUE, type = "cairo-png", , family="Myriad Pro light")