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!
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.
theme(plot.title = element_text(size = 12, face = "bold"),
legend.title=element_text(size=10),
legend.text=element_text(size=9))
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)))
一个更简单但同样有效的选择是:
+ theme_bw(base_size=X)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.