statquant
statquant

Reputation: 14400

How can I scale the label size of ggplot2 plots in rmarkdown

Hello I am generating report with rmarkdown I decided to use ggplot2 graphs as it seems that knitr rmarkdown ggplot2 works better together.

I'd like to globally increase the axis labels, tick label, title of my ggplot2 plots in the html_notebook document rmarkdown::render'ed.

Can I do this in the yaml or by setting something in a global chunk option ?

Upvotes: 5

Views: 2181

Answers (2)

Roccer
Roccer

Reputation: 919

Adding theme_bw(base_size = 8) helped me to scale the whole plot down. Supposedly also works with other themes.

Upvotes: -1

mtoto
mtoto

Reputation: 24198

You could use theme_update() in the setup chunk of your rmarkdown document to modify the active theme, overwriting the defaults for all subsequent plots. For example:

```{r setup, include=FALSE}
library(ggplot2)
theme_update(# axis labels
             axis.title = element_text(size = 30),
             # tick labels
             axis.text = element_text(size = 20),
             # title 
             title = element_text(size = 50))

```

Upvotes: 10

Related Questions