Skip to content

plot_annotation titles are removed when assembling or wrapping plots #209

Description

@msto

Hi,

I've found that titles added to a plot assembly are removed when trying to combine multiple assemblies into a larger figure.

I've extended the example in the assembly documentation page to demonstrate the issue. I'm able to add "Row1" and "Row2" to assemblies of the first and second plots and third and fourth plots, but these titles are removed when combining the assemblies with the stack operator (/) or wrap_plots().

I think this is a bug and not intended behavior, as using wrap_plots() with ncol=1 has the expected behavior of treating the sub-assemblies as individual plots, but please let me know if this is intended, or if I can add any other info.

Thanks!

library(ggplot2)
library(patchwork)

p1 <- ggplot(mtcars) + 
  geom_point(aes(mpg, disp)) + 
  ggtitle('Plot 1')

p2 <- ggplot(mtcars) + 
  geom_boxplot(aes(gear, disp, group = gear)) + 
  ggtitle('Plot 2')

p3 <- ggplot(mtcars) + 
  geom_point(aes(hp, wt, colour = mpg)) + 
  ggtitle('Plot 3')

p4 <- ggplot(mtcars) + 
  geom_bar(aes(gear)) + 
  facet_wrap(~cyl) + 
  ggtitle('Plot 4')
combo1 <- (p1 + p2) + plot_annotation("Row 1")
combo1

combo1

combo2 <- (p3 + p4) + plot_annotation("Row 2")
combo2

combo2

combo1 / combo2

stacked

wrap_plots(combo1, combo2, ncol=1)

wrapped

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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