Skip to main content

PlotGrid

Struct PlotGrid 

Source
pub struct PlotGrid { /* private fields */ }
Expand description

A patchwork-style arrangement of plots rendered into one SVG on the plotters-free native path.

  • cells fill row-major (or column-major with byrow(false)) across ncol / nrow (default: a near-square grid; a | b is one row, a / b one column);
  • widths / heights set relative column widths / row heights;
  • title / subtitle / caption annotate the whole grid;
  • tag_levels tags panels a, b, … (A, 1, roman, custom) in reading order, through nested grids;
  • collect_legends removes the sub-plots’ legends and draws each distinct legend once beside the grid (identical legends are de-duplicated).

Nested grids keep their own layout and annotations; tagging and legend collection are controlled by the outermost grid.

Implementations§

Source§

impl PlotGrid

Source

pub fn new() -> Self

Source

pub fn add(self, cell: impl Into<GridCell>) -> Self

Append a plot (or a nested grid) as the next cell.

Source

pub fn add_all(self, plots: impl IntoIterator<Item = GGPlot>) -> Self

Append several plots.

Source

pub fn add_spacer(self) -> Self

Append an empty cell (patchwork’s plot_spacer()).

Source

pub fn ncol(self, n: usize) -> Self

Number of columns.

Source

pub fn nrow(self, n: usize) -> Self

Number of rows.

Source

pub fn byrow(self, byrow: bool) -> Self

Fill cells row by row (default) or column by column.

Source

pub fn widths(self, widths: &[f64]) -> Self

Relative column widths (recycled; non-positive / non-finite = 1).

Source

pub fn heights(self, heights: &[f64]) -> Self

Relative row heights (recycled; non-positive / non-finite = 1).

Source

pub fn title(self, title: &str) -> Self

Title over the whole grid.

Source

pub fn subtitle(self, subtitle: &str) -> Self

Subtitle over the whole grid.

Source

pub fn caption(self, caption: &str) -> Self

Caption under the whole grid.

Source

pub fn tag_levels(self, levels: TagLevels) -> Self

Tag the panels (labs(tag) of each sub-plot is replaced).

Source

pub fn tag_affixes(self, prefix: &str, suffix: &str) -> Self

Text around each tag, e.g. ("(", ")") for (a).

Source

pub fn collect_legends(self, collect: bool) -> Self

Collect the sub-plots’ legends into one strip (identical legends are drawn once). Sub-plots with an inside or hidden legend keep it.

Source

pub fn legend_position(self, pos: GridLegendPosition) -> Self

Where collected legends go.

Source

pub fn spacing(self, px: f64) -> Self

Gap between cells, in px (default 0).

Source

pub fn theme(self, theme: Theme) -> Self

Theme for the grid’s own title/subtitle/caption and the collected legends’ text.

Source

pub fn len(&self) -> usize

Number of cells (plots, nested grids and spacers).

Source

pub fn is_empty(&self) -> bool

Whether the grid has no cells.

Source

pub fn render_svg_native(self) -> Result<String, GGError>

Render at 800×600.

Source

pub fn render_svg_native_with_size( self, w: u32, h: u32, ) -> Result<String, GGError>

Render the grid to one standalone SVG document of w×h px. The root carries data-grid="<rows> <cols>" (and no data-plot: each sub-<svg> has its own).

Source

pub fn render_svg_native_with_warnings( self, w: u32, h: u32, ) -> Result<(String, Vec<String>), GGError>

Like render_svg_native_with_size, also returning every sub-plot’s warnings, prefixed panel <tag>: .

Source

pub fn render_svg_native_at( self, x: f64, y: f64, w: u32, h: u32, ) -> Result<String, GGError>

Render as a nested <svg> fragment positioned at (x, y) — for composing the grid into a larger SVG (cf. GGPlot::render_svg_native_at).

Trait Implementations§

Source§

impl BitOr for PlotGrid

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: PlotGrid) -> PlotGrid

Performs the | operation. Read more
Source§

impl BitOr<GGPlot> for PlotGrid

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: GGPlot) -> PlotGrid

Performs the | operation. Read more
Source§

impl BitOr<PlotGrid> for GGPlot

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: PlotGrid) -> PlotGrid

Performs the | operation. Read more
Source§

impl Default for PlotGrid

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Div for PlotGrid

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: PlotGrid) -> PlotGrid

Performs the / operation. Read more
Source§

impl Div<GGPlot> for PlotGrid

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: GGPlot) -> PlotGrid

Performs the / operation. Read more
Source§

impl Div<PlotGrid> for GGPlot

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: PlotGrid) -> PlotGrid

Performs the / operation. Read more
Source§

impl From<PlotGrid> for GridCell

Source§

fn from(g: PlotGrid) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V