如何调整ggarrange ggpubr ggplot中的边距(轴元素消失)R

dss*_*333 3 r ggplot2 ggpubr

我想使用将 3 个图堆叠为 1 个图ggarrange,但底部图的 x 轴元素(日期)总是消失。

例如,这里plot_3缺少 (Z) 的轴元素。

ggarrange(plot_1, plot_2, plot_3 + rremove("x.text"), 
          nrow = 3, align = "h")
Run Code Online (Sandbox Code Playgroud)

结果1

当我更改顺序时,plot_2(Y) 的轴元素现在消失了。

ggarrange(plot_1, plot_3, plot_2 + rremove("x.text"), 
          nrow = 3, align = "h")
Run Code Online (Sandbox Code Playgroud)

结果2

我尝试调整每个的边距ggplot,但同样的问题仍然存在。所以,我想这一定与 中的边距有关ggarrange

顺便说一句,我还尝试删除前两个图的所有 x 轴标题,并保留最后一个(底部)图的标题,但同样,日期仍然丢失。

小智 5

I think that the function theme() would be useful

ggarrange(plot_1, plot_2, plot_3 + rremove("x.text"), 
          nrow = 3, align = "h")+
  theme(plot.margin = margin(0.1,0.1,2,0.1, "cm")) 

 
Run Code Online (Sandbox Code Playgroud)