Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misaliged plots when using patchwork #46

Open
antgon opened this issue Mar 29, 2022 · 1 comment
Open

Misaliged plots when using patchwork #46

antgon opened this issue Mar 29, 2022 · 1 comment

Comments

@antgon
Copy link

antgon commented Mar 29, 2022

If a "broken" plot is combined with other plots using patchwork the axes are misaligned, e.g.:

library(tidyverse)
library(ggbreak)
library(patchwork)

df <- tibble( x = seq(0, 2*pi, 0.01),
    y1 = sin(x),
    y2 = sin(x * 2) + 100)

plt1 <- ggplot(df, aes(x, y1)) + geom_line()
plt2 <- plt1 + scale_x_break(c(1, 3), expand = F)
plt3 <- ggplot(df, aes(x, y2)) + geom_line()

(plt2 + plt1) / (plt1 + plt3)
# Same with plot_layout, as in
# plt2 + plt1 + plt1 + plt3 + plot_layout(nrow=2)

Screenshot from 2022-03-29 18-08-59


Incidentally, if I try to combine the same plots with cowplot instead of patchwork, the ggbreak::scale_x_break layer disappears:

library(cowplot)
plot_grid(plt2, plt1, plt1, plt3, nrow=2, align="hv")

Screenshot from 2022-03-29 18-22-43

@cjpratt94
Copy link

I would like to second the above issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants