Skip to content
save_facets

save_facets

Mojo function 🡭

save_facets

fn def save_facets(plots: List[AnyChart], cols: Int, path: String, shared_y_scale: Bool = False, shared_x_scale: Bool = False, dpi: Float64 = 72, tight: Bool = False)

save()’s render_facets()/render_facets_svg() counterpart; see save_layers() for the shared format/empty behavior.

Each entry in plots is an independent Plot (its own data, labels, theme, mark), laid out into a grid of cols columns; _require_uniform_size requires every plot to have the same .size(). Build each cell’s Plot, or use scatter_facets() to make panels from a DataFrame. shared_y_scale makes every cell share one y-domain (see _render_facets_generic for its Mark.POINT/LINE/ EFFECT_SCATTER-only scope).

dpi and tight mean what they do for save() (#701): dpi sets a raster export’s pixels per inch, scaling every cell together so the grid keeps its proportions, and the vector formats ignore it; tight crops every format to the figure’s ink.

See the Cookbook’s “Facets” and “Shared Facet Scale” recipes (docs/cookbook_recipes/).

SVG output writes accessible markup automatically from plots[0]’s .labels(), as a best-effort document title for the whole grid – each cell can carry its own visible title, but the <svg> root needs exactly one aria-label/<title>. Give plots[0] a title that describes the grid as a whole (or call write_accessible_svg() directly) when that matters.

Args:

  • plots (List[AnyChart])
  • cols (Int)
  • path (String)
  • shared_y_scale (Bool)
  • shared_x_scale (Bool)
  • dpi (Float64)
  • tight (Bool)

Raises:

fn def save_facets[*Cs: ChartLike](*charts: *Cs.values, *, cols: Int, path: String, shared_y_scale: Bool = False, shared_x_scale: Bool = False, dpi: Float64 = 72, tight: Bool = False)

save_facets(plots, cols, path) for charts named one by one: save_facets(a, b, cols=2, path="facets.svg").

Parameters:

  • *Cs (ChartLike)

Args:

  • *charts (*Cs.values)
  • cols (Int)
  • path (String)
  • shared_y_scale (Bool)
  • shared_x_scale (Bool)
  • dpi (Float64)
  • tight (Bool)

Raises: