
Calculate plot dimensions with aspect ratio and legend consideration
Source:R/05-utils.R
calculate_plot_dimensions.RdCentralized helper for computing plot height and width based on content, aspect ratio, legend position, and optional bounds. Replaces per-function ad-hoc dimension logic.
Usage
calculate_plot_dimensions(
base_height = 4.5,
base_width = NULL,
aspect.ratio = NULL,
n_x = NULL,
n_y = NULL,
x_scale = 0.5,
y_scale = 0.5,
legend.position = "right",
legend.direction = "vertical",
legend_n = 1,
legend_nchar = 5,
flip = FALSE,
min_dim = 3,
max_dim = 12
)Arguments
- base_height
Base height (inches) before legend adjustments
- base_width
Base width; if NULL derived from aspect.ratio
- aspect.ratio
Panel height/width ratio; NULL = independent sizing
- n_x
Number of categories on x-axis (width scaling)
- n_y
Number of categories on y-axis (height scaling)
- x_scale
Per-category width increment
- y_scale
Per-category height increment
- legend.position
Legend position string
- legend.direction
Legend direction string
- legend_n
Number of legend items (for horizontal legend row estimation)
- legend_nchar
Max characters in legend labels
- flip
Whether coordinates are flipped
- min_dim
Minimum dimension (inches)
- max_dim
Maximum dimension (inches)