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

Design is not consistent when swapping figures that have fixed aspect ratio. #274

Closed
ltuijnder opened this issue Aug 26, 2021 · 0 comments
Closed
Labels
bug an unexpected problem or unintended behavior

Comments

@ltuijnder
Copy link

While working on a solution for issue: #271 I stumbled upon the following bug:

Say I have 3 figures with aspect ratio 1 and I want two of them to be nicely placed below a the third:
I can get the desired result using the following code:

library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + theme(aspect.ratio = 1)

design <- "
  33
  12
    "
p1 + p1 + p1 + plot_layout(design = design, height = unit(c(2,-1),c("null","null")))

Created on 2021-08-26 by the reprex package (v2.0.1)

However, when I just permutate the numbers in design I get another result:

library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + theme(aspect.ratio = 1)
design <- "
  11
  23
    "
p1 + p1 + p1 + plot_layout(design = design, height = unit(c(2,-1),c("null","null")))

Created on 2021-08-26 by the reprex package (v2.0.1)

I would have expected the exact same figure as the layout specification is the same and the 3 subplots are identical.


Note that this issue does not seem to occur when the figure up top does not have an aspect ratio specified.

@thomasp85 thomasp85 added the bug an unexpected problem or unintended behavior label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants