An excellent example is provided here.
Summarizing, you need to install extrafont
and use font_install('fontcm')
to get the 'Computer Modern' fonts. Then with respect to ggplot
you can use the theme
and element_text
functions to modify fonts.
For example:
p <- qplot(seq(5), seq(5)) +
xlab("Made with CM fonts") + ylab("Made with CM fonts") +
ggtitle("Made with CM fonts")
# With the new fonts
p + theme(text = element_text(size=16, family="CM Roman"),
axis.title.x = element_text(face="italic", family="CM Sans"),
axis.title.y = element_text(face="bold", family= "CM Roman Greek"))
Where the title is 'Computer Modern' and the axis titles are CM Sans and CM Roman Greek with italic and bold typeface.