Skip to content

Figure

Mojo struct 🡭

Figure

@memory_only
struct Figure

A composite chart – several Plots laid out in grid cells – that has not been rendered yet (#697).

What Plot is for one chart: construction stores the layout and draws nothing, and the same value exports to any format through render(), render_svg(), render_pdf() or save(), exactly as a Plot does. jointplot(), pairplot() and clustermap() return one, so save(pairplot(...), "pairs.svg") works the way save(scatter(x, y), "chart.svg") does.

It holds render_grid()’s arguments, and rendering one is render_grid() over them; a uniform facet grid is the case of one cell per plot with equal tracks, which is how pairplot() builds its figure.

Fields

  • plots (List[AnyChart]): The charts, one per cell.
  • cells (List[GridCell]): Where each plot goes.
  • width (Int): Figure width, in points (1/72 inch), as Plot.size().
  • height (Int): Figure height, in points.
  • row_weights (List[Float64]): Relative row heights, empty for equal rows.
  • col_weights (List[Float64]): Relative column widths, empty for equal columns.
  • shared_y_scale (Bool): Give every cell one y-domain.
  • shared_x_scale (Bool): Give every cell one x-domain.
  • align_axes (Bool): Share plot-rect edges down each column and across each row.
  • title (String): A figure title above the cells; empty for none.

Implemented traits

AnyType, Copyable, Deinitable, Movable

Methods

__init__

fn def __init__(out self, var plots: List[AnyChart], var cells: List[GridCell], width: Int, height: Int, var row_weights: List[Float64] = List(), var col_weights: List[Float64] = List(), shared_y_scale: Bool = False, shared_x_scale: Bool = False, align_axes: Bool = False, title: String = "")

Store a layout; nothing is drawn or checked until it is rendered, as with Plot.

Args:

  • plots (List[AnyChart]): The charts, one per cell.
  • cells (List[GridCell]): Where each plot goes.
  • width (Int): Figure width in points.
  • height (Int): Figure height in points.
  • row_weights (List[Float64]): Relative row heights, empty for equal rows.
  • col_weights (List[Float64]): Relative column widths, empty for equal columns.
  • shared_y_scale (Bool): Give every cell one y-domain.
  • shared_x_scale (Bool): Give every cell one x-domain. The continuous marks pool their x extents; categorical cells must name the same categories in the same order.
  • align_axes (Bool): Share plot-rect edges, as render_grid().
  • title (String): A figure title above the cells; empty for none.
  • self (Self)

Returns:

Self