微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 ggarrange

如何解决使用 ggarrange

我正在尝试使用 ggarrange 创建一组图。我正在使用“标签”参数为每个图创建一个标题,但根据标题的长度,每个图的定位会有所不同。似乎标题越长,标签打印得越靠右。

如何使所有标签左对齐?我试过使用 hjustlabel.x,但这并没有改变。

这是我的代码和情节:

ggarrange(plot1,plot2,plot3,common.legend=TRUE,labels = c("asdf","asdfasdf","asdfasdfasdfsadfasdf"),hjust=-0.8,ncol = 2,nrow = 2)

enter image description here

解决方法

我不确定这是否是解决您问题的捷径,但尝试这样做可能会有所帮助:

    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)

您可以检查:https://www.royfrancis.com/customising-ggplot2/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。