有没有办法改变ggplot2中的图例项目之间的间距? [英] Is there a way to change the spacing between legend items in ggplot2?
本文介绍了有没有办法改变ggplot2中的图例项目之间的间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法改变ggplot2中的图例项目之间的间距?我目前有
legend.position =top
会自动产生一个水平图例。但是,项目的间距非常接近,我想知道如何将它们间隔得更远。 我认为最好的选择是在指南
中使用 guide_legend
:
<$ p $ b $
p + guides(fill = guide_legend(
keywidth = 0.1,
keyheight = 0.1,
default.unit =inch)
)
使用 default.unit
,无需加载 grid
包。
Is there a way to change the spacing between legend items in ggplot2? I currently have
legend.position ="top"
which automatically produces a horizontal legend. However, the spacing of the items is very close together and I am wondering how to space them farther apart.
解决方案
I think the best option is to use guide_legend
within guides
:
p + guides(fill=guide_legend(
keywidth=0.1,
keyheight=0.1,
default.unit="inch")
)
Note the use of default.unit
, no need to load grid
package.
这篇关于有没有办法改变ggplot2中的图例项目之间的间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文