gpt4 book ai didi

r - 使用 ggarrange 定位 ggplot 标签的问题

转载 作者:行者123 更新时间:2023-12-05 04:50:05 27 4
gpt4 key购买 nike

我正在尝试使用 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/

关于r - 使用 ggarrange 定位 ggplot 标签的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67376630/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com