Report.add_chart

add_chart

add_chart(figure: object, *, title: str, caption: str | None = None, notes: str | None = None, id: str | None = None) -> ReportItem

Add a Matplotlib, plotnine, or Altair chart as static SVG.

Plotnine charts are converted to Matplotlib figures. Altair charts use Altair's SVG exporter, which optionally needs vl-convert-python. No JavaScript is included in the resulting HTML report.

Parameters:
  • figure (object) –

    A Matplotlib Figure, plotnine plot, or Altair chart.

  • title (str) –

    Visible chart heading.

  • caption (str | None, default: None ) –

    Optional caption.

  • notes (str | None, default: None ) –

    Optional explanatory notes.

  • id (str | None, default: None ) –

    Optional stable component ID.

Returns:

Example

figure = ps.plots.histogram(df, 'age')
report.add_chart(figure, title='Age distribution')

Research note

Only aggregated plots should be shared when observations are sensitive.

← Reports API