我正在尝试用ggarrange创建一个绘图面板,我使用“labels”参数为每个绘图创建一个标题,但是根据标题的长度,每个绘图的位置都不一样。看起来标题越长,标签打印得越靠右。
如何使所有标签左对齐?我尝试过使用hjust
或label.x
,但这并没有改变什么。
这是我的代码和情节:
ggarrange(plot1,plot2,plot3,
common.legend=TRUE,
labels = c("asdf", "asdfasdf", "asdfasdfasdfsadfasdf"),
hjust=-0.8,
ncol = 2, nrow = 2)
3条答案
按热度按时间7fhtutme1#
我不知道这是否是你问题的捷径,但试试这个可能会有帮助:
您可以检查:https://www.royfrancis.com/customising-ggplot2/
zf9nrax12#
在我看来,您可以先使用
geom_text()
为每个图设置标签,然后使用ggarrange()
将所有子图放在一起。u2nhd7ah3#
hjust适用于水平移位,vjust适用于垂直移位。在我的例子中,我保持hjust=-7以保持标签在中间,它起作用了。你必须根据你的数据尝试一下。