[英]increase legend font size ggplot2
Is there a way to increase the font size in ggplot2
? 有没有办法增加
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. 我想我需要在
theme
函数中指定类似legend.key.width = unit(2, "line")
的东西,但是它用于调整图例中的键,而不是字体大小。 Thanks! 谢谢!
You can use theme_get()
to display the possible options for theme. 您可以使用
theme_get()
显示主题的可能选项。 You can control the legend font size using: 您可以使用以下方法控制图例字体大小:
+ theme(legend.text=element_text(size=X))
replacing X with the desired size. 用所需的尺寸替换X.
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. 您还可以使用
rel()
函数指定相对于主题中包含的base_size
的字体大小,例如theme_bw()
(其中base_size
为11)。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.