Skip to content

Patchwork of patwchrok does not handle title properly #434

Description

@dmongin

related to #432, I noticed another error:

If I do the following to avoid the legend error (as suggested here https://stackoverflow.com/questions/79663257/how-to-handle-legend-properly-with-patchwork/79663866?noredirect=1#comment140511944_79663866)

p1 <- ggplot(iris,aes(Sepal.Length,Sepal.Width,color = Species))+
  geom_point() 

first_plot <- p1 + 
  inset_element(p1 + guides(color = "none"), 
                right = 0.5,left = 0,
                bottom = .55,top =  1) + 
  plot_annotation(title = "plouf1")

Image

p2 <- ggplot(iris,aes(Sepal.Length,Sepal.Width,color = Petal.Width))+
  geom_point()

second_plot <- p2 + inset_element(p2+ guides(color = "none"), 
                                  right = 0.5,left = 0,
                                  bottom = .55,top =  1) + 
  plot_annotation(title = "plouf2")

Image

Each plot has his title. But when doing:

first_plot + second_plot

Image

I just have the first title, and even worst:

(first_plot + second_plot)/(first_plot + second_plot)

Image

Here I have no title anymore

Activity

  1. Breeze-Hu commented on Jun 18, 2025

    @Breeze-Hu

    I feel as if the situation is somewhat similar to this issue: #416

    Looking forward to the developer's fix :-)

  2. bug1303 commented on Mar 17, 2026

    @bug1303

    Had a similar issue and found a work-around here: https://stackoverflow.com/questions/69970971/plot-annotations-disappear-via-patchwork-in-r

    You can do

    wrap_elements(first_plot) + wrap_elements(second_plot)

    or even:

    (wrap_elements(first_plot) + wrap_elements(second_plot))/(wrap_elements(first_plot) + wrap_elements(second_plot))

    Also described in the docs (https://patchwork.data-imaginist.com/articles/guides/annotation.html#titles-subtitles-and-captions):
    "It is important to note that plot annotations only have an effect on the top-level patchwork. Any annotation added to nested patchworks are (currently) lost. If you need to have annotations for a nested patchwork you’ll need to wrap it in wrap_elements() with the side-effect that alignment no longer works."

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