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.
Asked
Active
Viewed 8.2k times
2 Answers
129
Use theme_set()
theme_set(theme_gray(base_size = 18))
qplot(1:10, 1:10)

Luciano Selzer
- 9,806
- 3
- 42
- 40
-
13Very useful! In case anyone is interested, the default text size is **11** (`theme_gray()$text$size`) – Keith Hughitt Jul 11 '16 at 21:28
-
2under new ggplot2 2.2.1 I do not see `base_size` under theme listed but it seems to work. I noticed my `geom_text` for showing text of a mean is not inheriting this base_size change. Anyone have luck with getting this to work – micstr Feb 10 '17 at 14:40
61
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)

Andrew Brēza
- 7,705
- 3
- 34
- 40

Thierry
- 18,049
- 5
- 48
- 66