Skip to content

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

@phispu

Description

@phispu

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions