Skip to content
save_grid

save_grid

Mojo function 🡭

save_grid

fn def save_grid(plots: List[AnyChart], cells: List[GridCell], width: Int, height: Int, path: String, row_weights: List[Float64] = List(), col_weights: List[Float64] = List(), shared_y_scale: Bool = False, shared_x_scale: Bool = False, align_axes: Bool = False, title: String = "", dpi: Float64 = 72, tight: Bool = False)

render_grid()’s counterpart that writes a file, picking the format from plots[0]’s theme or the path’s extension.

SVG output takes its accessible markup from plots[0]’s .labels(), the same best-effort rule save_facets() uses: the <svg> root needs exactly one title for a figure with many cells.

Args:

  • plots (List[AnyChart]): The charts, one per cell.
  • cells (List[GridCell]): Where each plot goes.
  • width (Int): Figure width.
  • height (Int): Figure height.
  • path (String): Where to write.
  • 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, as render_grid().
  • dpi (Float64): Pixels per inch for a raster export, as save()’s (#701): width and height are points, so 300 scales the figure, every cell’s Theme.scale and the title band together. The vector formats ignore it.
  • tight (Bool): Crop every format to the figure’s ink, as save()’s.

Raises:

Error: Whatever render_grid() raises, or a write failure.