You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plot_layout(guides = "collect") no longer working #455
With ggplot 3.5.1, patchwork 1.3.0 and R4.4.2, the guides from a histogram and a density plot as specified below were merged into one as long as the color was removed from the density plot. I have just reloaded that configuration and tested that the guides are correctly collected into one.
With ggplot 4.0, patchwork 1.3.2 and the dev version 1.3.2.9 in R4.5.1 this no longer works. No matter what I do I get two legends as shown below. I can't see why these two scales would be different. I don't know if change is due to the new ggplot2 configuration or something in patchwork. Any chance the functionality could be returned?
I run into similar troubles here as well for examples I am quite sure would have worked before.
Want to note that it works if geoms are the same, though:
library(patchwork)
library(ggplot2)
data("iris")
## works if geom is the samehist.group<- ggplot(iris, aes(Sepal.Length, fill=Species)) +
geom_histogram()
(hist.group|hist.group) +
plot_layout(guides="collect") &
theme(legend.position="bottom")
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
Activity
brueckmann commentedon Nov 20, 2025
May I add on, that on this page, https://patchwork.data-imaginist.com/reference/wrap_plots.html an example is mentioned ". If you modify default guide "position" with theme(legend.position=...) while also collecting guides you must apply that change to the overall patchwork (see example)." but I cannot find this example under the examples in the link mentioned.
(Updated for clarity.)
z3tt commentedon Mar 16, 2026
I run into similar troubles here as well for examples I am quite sure would have worked before.
Want to note that it works if geoms are the same, though:
Created on 2026-03-16 with reprex v2.1.1