patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

Patchwork of patwchrok does not handle properly legends

Open dmongin opened this issue 9 months ago • 0 comments

It seems to me that this was working before. I am using patchwork 1.3.0 , with ggplot2 3.5.2.

Here is my problem:

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

first_plot <- p1 + inset_element(p1, right = 0.5,left = -.2,
                   bottom = .55,top =  1) + 
  plot_layout(guides = "collect") + 
  plot_annotation(title = "plouf")

Image

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

second_plot <- p2 + inset_element(p2, right = 0.5,left = -.2,
                                 bottom = .55,top =  1) + 
  plot_layout(guides = "collect") + 
  plot_annotation(title = "plouf")

Image

But:

first_plot + second_plot

Produce this werid situation where the two legend overlap on the right:

Image

dmongin avatar Jun 12 '25 09:06 dmongin