How to change the default font size in ggplot2

RGgplot2DefaultFont Size

R Problem Overview


I'd like to know if it is possible to change some default parameters of ggplot2 graphics, like font size for instance, for a whole R session. The idea is to avoid setting them for each plot.

R Solutions


Solution 1 - R

Use theme_set()

theme_set(theme_gray(base_size = 18))
qplot(1:10, 1:10)

enter image description here

Solution 2 - R

Use theme_set if you want to update for the remainder of your active session:

theme_set(theme_grey(base_size = 18)) 

If you only want to change one graph you can set the base_size in the theme:

qplot(1:10, 1:10) + theme_grey(base_size = 18) 
ggplot(mtcars, aes(x = mpg, y = cyl)) + 
geom_point() +
theme_grey(base_size = 18) 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjeannotView Question on Stackoverflow
Solution 1 - RLuciano SelzerView Answer on Stackoverflow
Solution 2 - RThierryView Answer on Stackoverflow