问题描述
我正在尝试使用 ggarrange 创建一组图。我正在使用“标签”参数为每个图创建一个标题,但根据标题的长度,每个图的定位会有所不同。似乎标题越长,标签打印得越靠右。
如何使所有标签左对齐?我试过使用 hjust
或 label.x
,但这并没有改变。
这是我的代码和情节:
ggarrange(plot1,plot2,plot3,common.legend=TRUE,labels = c("asdf","asdfasdf","asdfasdfasdfsadfasdf"),hjust=-0.8,ncol = 2,nrow = 2)
解决方法
我不确定这是否是解决您问题的捷径,但尝试这样做可能会有所帮助:
plot1 <- plot1 + theme(legend.position="left")+
labs(title="asdf")
plot2<- plot2 + theme(legend.position="left")+
labs(title="asdfasf")
plot3 <- plot3 + theme(legend.position="left")+
labs(title="asdfasdfasfdsas")
ggarrange(plot1,plot2,plot3,common.legend=TRUE,hjust=-0.8,ncol = 2,nrow = 2)