patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

Add legend between patchwork main title and plot titles

Open zx8754 opened this issue 5 years ago • 0 comments

Relevant post at SO:

  • https://stackoverflow.com/q/65733641/680068

I submitted the answer (also posted below) using cowplot::get_legend, is there a way of doing this without cowplot?

Solution:

# get the legend
l <- cowplot::get_legend(p1 + theme(legend.position = "top"))

(cowplot::plot_grid(l) / (p1 + p2)) + 
  plot_layout(heights = unit(c(1, 5), "cm")) +
  plot_annotation(title = "main title") &
  theme(legend.position = "none")

image

zx8754 avatar Jan 15 '21 10:01 zx8754