简体   繁体   English

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

[英]How to adjust margin in ggarrange ggpubr ggplot (axis elements disappear) R

I want to stack 3 plots into 1 using ggarrange but the x-axis elements (dates) of the bottom plot are always disappeared.我想使用ggarrange将 3 个图堆叠成 1 ggarrange但底部图的 x 轴元素(日期)总是消失。

For example, here axis elements of plot_3 (Z) are missing.例如,这里缺少plot_3 (Z) 的轴元素。

ggarrange(plot_1, plot_2, plot_3 + rremove("x.text"), 
          nrow = 3, align = "h")

结果 1

And when I change the order, axis elements of plot_2 (Y) are now disappeared.当我更改顺序时, plot_2 (Y) 的轴元素现在消失了。

ggarrange(plot_1, plot_3, plot_2 + rremove("x.text"), 
          nrow = 3, align = "h")

结果 2

I tried to adjust the margins in each ggplot , but the same problem persists.我试图调整每个ggplot的边距,但同样的问题仍然存在。 So, I guess it must be something to do with the margins in ggarrange .所以,我想这一定与ggarrange的边距ggarrange

By the way, I also tried to remove all the x-axis title of the first two plots, and keep the title of the last (bottom) plot, but again, the dates are still missing.顺便说一句,我还尝试删除前两个图的所有 x 轴标题,并保留最后一个(底部)图的标题,但同样,日期仍然丢失。

I think that the function theme() would be useful我认为函数 theme() 会很有用

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")) 

 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM