pl1 <- p1 +labs(tag =NULL, title ="Plot One") +theme(legend.position ="none")pl2 <- p2 +labs(tag =NULL, title ="Plot Two") +theme(legend.position ="none")pl3 <- p3 +labs(tag =NULL, title ="Plot Three") +theme(legend.position ="none")
Add Labels
(pl1 + pl2) / pl3 +plot_annotation(tag_levels ="1", tag_prefix ="P", title ="An overarching title for all 3 plots, placed on the very top while all other titles are sitting below the tags.")
text <-tibble(x =0, y =0, label ="Lorem ipsum dolor sit amet, **consectetur adipiscing elit**, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation <b style='color:#000080;'>ullamco laboris nisi</b> ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat <b style='color:#cc0000;'>cupidatat non proident</b>, sunt in culpa qui officia deserunt mollit anim id est laborum.")pt <-ggplot(text, aes(x = x, y = y)) + ggtext::geom_textbox(aes(label = label),box.color =NA, width =unit(23, "lines"),family ="Pally", color ="grey40", size =6.5, lineheight =1.4 ) +coord_cartesian(expand =FALSE, clip ="off") +theme_void()pt
Add Text
(p1 + pt) / p3
Add Inset Plots
pl1 +inset_element(pl2, l = .6, b = .1, r =1, t = .6)
Add Inset Plots
pl1 +inset_element(pl2, l = .6, b =0, r =1, t = .5, align_to ='full')
Add Inset Plots
(pl1 +inset_element(pl2, l = .6, b = .1, r =1, t = .6) + pt) / pl3
Recap
guides are the combination of scales and legends
legends can be either modified with the guide_* function in scale_*() or guides() and with the theme() component qualitative
… while quantitative guides are colorbar, colorsteps or bins
{patchwork} is the most modern and simplest way to compose plots
use +, / and | to combine plots
use plot_layout() to adjust the layout, widths and heights
use plot_annotation() to add tags and general labels