Default font type in R Markdown

ggplot2
fonts
plot

#1

I am knitting an R Markdown to PDF and am looking to have my graphs and maps (some created with ggplot2 and others with base::plot) to have the same look as general R Markdown text. Right now my graphs seem out of place and I didn't know what the default font of R Markdown was so that I can use the same one in the graphs/plots. For example, the boxplot text is very different from the table made with knitr::kable


#2

Hi there,

The RMarkdown output is based on LaTeX, and the default LaTeX font is Computer Modern. You will need to download and install the font on your computer. The CMU Serif version of this font is probably the one you want.

To use it in ggplot2, you may find this R Cookbook page helpful, or you can check out the extrafonts :package: - I've never used it but it seems like it may suit your needs.

Hope this helps!