The align_plots() function is the core engine for data-free composition in the ggalign package. It enables users to arrange multiple plots and graphical objects into a structured layout, with fine control over spacing, alignment, size, and guide collection — all independent of the underlying data or coordinate systems.
This section provides a comprehensive breakdown of its key arguments, along with how they affect the final layout.
Code
library(ggalign)#> Loading required package: ggplot2#> ========================================#> ggalign version 1.1.0.9000#> #> If you use it in published research, please cite: #> Peng, Y.; Jiang, S.; Song, Y.; et al. ggalign: Bridging the Grammar of Graphics and Biological Multilayered Complexity. Advanced Science. 2025. doi:10.1002/advs.202507799#> ========================================
Like patchwork, if no specific layout is provided, align_plots() will attempt to create a grid that is as square as possible, with each column and row taking up equal space:
Empty cells will still take up layout space unless you explicitly adjust sizes.
3.5 Guide Legends
By default, each plot keeps its own guides. Use the guides argument to collect and consolidate them to specific sides, which should be of a single string with following elements:
"t" — collect top guide legends
"r" — collect right guide legends
"b" — collect bottom guide legends
"l" — collect left guide legends
"i" - Collect guide legends inside the plot panel area (plot panel guides)