Die Website zu unserem Forum 2016 ist jetzt online: Risikomanagement mit Simulationen erfolgreich gestalten findet am 10. März 2016 in Hamburg statt.
Kategorien
Die Website zu unserem Forum 2016 ist jetzt online: Risikomanagement mit Simulationen erfolgreich gestalten findet am 10. März 2016 in Hamburg statt.
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:
library(extrafont)
font_import()
Look up the name of the font in the results of
fonts()
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")