The pdf
and postscript
graphic devices in R have special functions that handle the translation of an R graphics font family name to a PostScript or PDF file. In this recipe, we will see how to choose the fonts for these vector formats.
We will only use the base graphics functions for this recipe. So, just open up the R prompt and type in the following code. You might wish to save the code as an R script for later use.
Let's create a PDF of an rnorm()
graph with the title and axis annotations in the Avant Garde font:
pdf("fonts.pdf",family="AvantGarde") plot(rnorm(100),main="Random Normal Distribution") dev.off()
To save the same graph as a postscript file, we use the following code:
postscript("fonts.ps",family="AvantGarde") plot(rnorm(100),main="Random Normal Distribution") dev.off()