patchwork
patchwork copied to clipboard
theme_void seems to overwrite guides = "collect"
When using theme_void, guides = "collect" seems to stop working. Maybe theme_void is overwriting themes set by guides = "collect"? Also, global setting such as & theme(legend.justification = "...")
seems to fail in this case.
I stumbled upon this on answering a question on stackoverflow. Interestingly, guides between theme_void plots are being collected. (see last plot in this issue, and the SO example plot)
library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp, colour = mpg)) +
scale_color_continuous(limits = c(0,30))
p2 <- ggplot(mtcars) +
geom_point(aes(hp, wt, colour = mpg)) +
scale_color_continuous(limits = c(0,30))
p1 + p2 +
plot_layout(guides = "collect")
p1 + p2 + theme_void() +
plot_layout(guides = "collect")
It works with other themes
p1 + p2 + theme_classic() +
plot_layout(guides = "collect")
When both plots are theme_void
, it works.
p1 + theme_void() + p2 + theme_void()+
plot_layout(guides = "collect")
Created on 2021-02-21 by the reprex package (v1.0.0)