Skip to main content

compute_subplot_rects

Function compute_subplot_rects 

Source
pub fn compute_subplot_rects(
    figure_width: f64,
    figure_height: f64,
    nrows: usize,
    ncols: usize,
    spacing: f64,
    outer_padding: f64,
) -> Vec<Rect>
Expand description

Computes subplot positions for a grid of axes.

Returns a Vec<Rect> with one entry per subplot cell in row-major order (left to right, top to bottom). Each rectangle represents the total available area for that subplot — callers should run compute_layout on each rect individually to determine the inner plot area and decoration positions.

§Arguments

  • figure_width — Total figure width in pixels.
  • figure_height — Total figure height in pixels.
  • nrows — Number of rows in the subplot grid.
  • ncols — Number of columns in the subplot grid.
  • spacing — Gap between adjacent subplots in pixels.
  • outer_padding — Padding between the figure edges and the outermost subplots.

§Panics

Panics if nrows or ncols is zero.