Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 335
statquant Avatar asked Mar 08 '23 10:03

statquant


1 Answers

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))

```
like image 58
mtoto Avatar answered Mar 10 '23 14:03

mtoto