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

plot_layout(axes = "collect") does not work in certain situations with a facet_wrap() #367

Closed
michaeltopper1 opened this issue Jul 23, 2024 · 0 comments

Comments

@michaeltopper1
Copy link

Hello,

It looks like the plot_layout(axes = "collect") does not work when one of the plots has a facet_wrap that has multiple rows.

Take the following example:

## In this example, the axes merge fails
library(tidyverse)

p6 <- mtcars %>% ggplot() + geom_point(aes(mpg, disp, color=cyl)) +
  labs(y = "Axes to Merge",
       x = "")

## setting the facet wrap to multiple rows
p7 <- ggplot(mtcars) + geom_point(aes(mpg, hp, color=cyl)) +
  facet_wrap(~cyl, ncol = 2) +
  labs(y = "Axes to Merge",
       x = "") 

p6 + p7 + plot_layout(guides='collect',
                      axes = "collect")

On the other hand, not having multiple rows in the p7 plot renders no issue.

## In this example, the axes merge is correct
library(tidyverse)

p6 <- mtcars %>% ggplot() + geom_point(aes(mpg, disp, color=cyl)) +
  labs(y = "Axes to Merge",
       x = "")

## not setting the facet_wrap to have multiple rows
p7 <- ggplot(mtcars) + geom_point(aes(mpg, hp, color=cyl)) +
  facet_wrap(~cyl) +
  labs(y = "Axes to Merge",
       x = "") 

p6 + p7 + plot_layout(guides='collect',
                      axes = "collect")

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

1 participant