tags:

views:

494

answers:

2
+3  Q: 

Fonts in R plots

What graphics devices let me use system fonts for text within charts? The base graphics system only has a small amount of documentation around the par(family=...) options.

Ideally I'd like to be able to use any font I can browse through a tool like xfontsel on Linux or the equivalent utilities on other platforms.

My current solution is to plot out as PDF and then use a 3rd party program to replace the fonts from within the PDF. This is not ideal.

+3  A: 

I was curious about this as well so after a little digging I found this blog post on the topic:

http://www.jameskeirstead.ca/general/changing-the-fonts-in-r-plots/

It's not as easy as selecting it from a font browsing tool, but it seems to work for any font you have on your system. I hope that helps.

anthony mcclosky
+2  A: 

I just worked on this issue this morning. I found that you can get a list of fonts 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 ...

So I then went about my business with this:

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