Is there a way to increase the font size in ggplot2
? I think I need to specify something like legend.key.width = unit(2, "line")
in the theme
function, but that is used to adjust the keys in legends, not the font sizes. Thanks!
Asked
Active
Viewed 2.9e+01k times
187

alittleboy
- 10,616
- 23
- 67
- 107
-
2I normally refer to `?theme` for these kinds of questions – Ricardo Saporta Dec 05 '13 at 18:29
4 Answers
332
You can use theme_get()
to display the possible options for theme.
You can control the legend font size using:
+ theme(legend.text=element_text(size=X))
replacing X with the desired size.

loki
- 9,816
- 7
- 56
- 82

Dominic Edwards
- 3,608
- 1
- 15
- 9
80
theme(plot.title = element_text(size = 12, face = "bold"),
legend.title=element_text(size=10),
legend.text=element_text(size=9))

PatrickT
- 10,037
- 9
- 76
- 111

Ashish Markanday
- 1,300
- 10
- 11
29
You can also specify the font size relative to the base_size
included in themes such as theme_bw()
(where base_size
is 11) using the rel()
function.
For example:
ggplot(mtcars, aes(disp, mpg, col=as.factor(cyl))) +
geom_point() +
theme_bw() +
theme(legend.text=element_text(size=rel(0.5)))

Megatron
- 15,909
- 12
- 89
- 97
-
-
5Given a base size of 11, and a 50% size relative to the parent, this would yield 5.5. – Megatron Aug 04 '20 at 13:54
11
A simpler but equally effective option would be:
+ theme_bw(base_size=X)

Jefferson Maia
- 143
- 1
- 2
-
17Careful. For me this changed other font sizes too (e.g. title, axis labels). – seane Mar 14 '17 at 20:47