[R] adjust font in ggplot2 to LaTeX document

Brian Diggs diggsb at ohsu.edu
Mon Oct 1 16:17:00 CEST 2012

On 9/30/2012 11:38 AM, Jonas Stein wrote:
> Hi,
> how can i adjust the font in a ggplot2 qplot so that it will look
> similar to the LaTeX font?
> Computer Modern Sans Serif in the same size would be nice.
> My output device is
> ggsave(filename="test.pdf", width=5.5, height=3, dpi=300)
> and i will include the graphic with 5.5 inch in LaTeX.
> I found some pages about that topic but all solutions that i found have
> been very complicate and confusing to me.
> But the articles have been from 2009 too, so i guess there will be
> some easy solution today...

There is a recent (late last month) blog post on this topic:


> Is "theme" the keyword to find the solution?

In ggplot2, the font family is controlled by the theme. "font family" 
will probably get more specific results.

> Or will i have to include a binary font file?

Possibly, but probably not since you would be using a font already 
present in the (final) PDF.

> Can someone give me a link to an example?
> Kind regards and thanks a lot,

Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

More information about the R-help mailing list