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(axis_title = "collect") does not work with facets. #388

Open
phispu opened this issue Sep 4, 2024 · 1 comment
Open

plot_layout(axis_title = "collect") does not work with facets. #388

phispu opened this issue Sep 4, 2024 · 1 comment

Comments

@phispu
Copy link

phispu commented Sep 4, 2024

The axis_title = "collect" argument in plot_layout doesn't seem to work with facets. I'm not sure if this might be a bug, or if it was intended?

In example 1 below, plot 3 (p3, no facets) can have its axis titles collected.

In examples 2 (p3_facet_x) and 3 (p3_facet_y), the faceted side doesn't have its axis title collected.

data(mtcars)
# Create plots
p1 <- ggplot(mtcars) + 
  geom_point(aes(mpg, disp)) + 
  ggtitle('Plot 1') +
  labs(x = 'X Label', y = 'Y Label')
p2 <- ggplot(mtcars) + 
  geom_point(aes(disp, hp)) + 
  ggtitle('Plot 2') +
  labs(x = 'X Label', y = 'Y Label')
p3 <- ggplot(mtcars) + 
  geom_point(aes(drat, wt)) + 
  ggtitle('Plot 3a') +
  labs(x = 'X Label', y = 'Y Label')
  # facet plots
p3_facet_x <- ggplot(mtcars) + 
  geom_point(aes(drat, wt)) + 
  facet_grid(. ~ gear) + 
  ggtitle('Plot 3b') +
  labs(x = 'X Label', y = 'Y Label')
p3_facet_y <- ggplot(mtcars) + 
  geom_point(aes(drat, wt)) + 
  facet_grid(gear ~ .) + 
  ggtitle('Plot 3c') +
  labs(x = 'X Label', y = 'Y Label')
# Example 1: axis titles collect
p1 + p2 + p3 + 
  plot_layout(axis_titles = 'collect')
# Example 2: x-axis does not collect all the way
p1 + p2 + p3_facet_x +
  plot_layout(axis_titles = 'collect')
# Example 3: y-axis does not collect all the way
p1 + p2 + p3_facet_y +
  plot_layout(axis_titles = 'collect')
@phispu phispu changed the title plot_layout(axis_title = "collect") does not work with facets. #bug plot_layout(axis_title = "collect") does not work with facets. Sep 4, 2024
@thomasp85
Copy link
Owner

Try with the dev version - this should be fixed

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