简体   繁体   English

将底轴与拼凑对齐?

[英]Align bottom axes with patchwork?

My problem is similar to this one: How to left-align faceted-plots with patchwork?我的问题与此类似: How to left-align faceted-plots with patchwork? . . I'm trying to align the bottom axes in patchwork.我试图在拼凑中对齐底轴。 My actual plot is a lot more complex than this MWE-- I've tried facet_wrap, ggarrange, and cowplot, and patchwork gets the closest to what I want by far.我实际的 plot 比这个 MWE 复杂得多——我已经尝试过 facet_wrap、ggarrange 和 cowplot,到目前为止,patchwork 最接近我想要的。 I'm so close to getting this right so any help would be really appreciated!我非常接近正确处理此问题,因此非常感谢您的帮助!

require(ggplot2)
require(patchwork)

g1 <- ggplot() + 
  geom_point(aes(x = sort(rnorm(100)), y = sort(rnorm(100)))) + 
  geom_abline(slope = 1, linetype = 'dashed') + 
  coord_fixed()
g2 <- ggplot() + 
  geom_point(aes(x = sort(rnorm(100)), y = 2*sort(rnorm(100)))) + 
  geom_abline(slope = 1, linetype = 'dashed') + 
  coord_fixed()
(g1 + g2) + plot_layout(widths = c(1,1))

在此处输入图像描述

If coord_fixed() is removed, then it works fine with ggarrange function of ggpubr package如果删除了coord_fixed() ,那么它可以与ggarrange package 的ggpubr function 一起正常工作

require(ggplot2)
library(ggpubr)

g1 <- ggplot() + 
  geom_point(aes(x = sort(rnorm(100)), y = sort(rnorm(100)))) + 
  geom_abline(slope = 1, linetype = 'dashed') 

g2 <- ggplot() + 
  geom_point(aes(x = sort(rnorm(100)), y = 2*sort(rnorm(100)))) + 
  geom_abline(slope = 1, linetype = 'dashed') 

ggarrange(g1, g2, ncol = 2)

在此处输入图像描述

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

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