Calculate each plot's preferred physical size and keep every plot at that size. The default publication layout searches compact asymmetric placements with aligned edges, while the ordered layout packs shorter rows continuously and centers them. Apply plot-specific styling before composing.
Usage
plot_autocompose(
plots,
ncol = NULL,
nrow = NULL,
panel_width = 45,
panel_height = 35,
margin = 2,
units = "mm",
save = NULL,
dpi = 300,
base_size = "auto",
label_autosize = TRUE,
target_aspect = 1.6,
target_width = NULL,
layout = c("publication", "rows"),
gutter = 4
)Arguments
- plots
A plot or list of plots accepted by
plot_autosize().- ncol, nrow
Number of columns and rows. Supplying either uses the ordered row layout.
- panel_width, panel_height
Base panel width and height.
- margin
Outer margin.
- units
Units for panel dimensions and margin. See
grid::unit().- save
NULLor a file name to save the fitted plot.- dpi
Resolution used when saving raster output.
- base_size
"auto"to harmonize ggplot and grid text to one inferred base size in points, a positive point size, orNULLto preserve each component's typography.- label_autosize
Whether to enlarge constant
geom_text,geom_label, and ggrepel label sizes when the panel has enough horizontal space.- target_aspect
Preferred overall width-to-height ratio when
ncolandnroware bothNULL.- target_width
Optional publication target width in
units. Limits canvas width to fit journal single-column (e.g. 85 mm) or double-column (e.g. 180 mm) constraints.- layout
"publication"for compact asymmetric placement or"rows"to preserve input order in rows.- gutter
Space between components in
unitsfor the publication layout.
Value
A wrapped plot with size and autosize attributes. Component sizes
are stored in attr(x, "autosize")$components.
Examples
p1 <- ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) +
ggplot2::geom_point()
p2 <- p1 + ggplot2::labs(title = "A wider plot title")
plot_autocompose(list(p1, p2), ncol = 2)