Skip to content

Plotting API

plot_fit

sars.plot_fit

plot_fit(fit: SARFit, ax: Axes | None = None, log: bool = False, scatter_kw: dict | None = None, line_kw: dict | None = None) -> plt.Axes

Plot a single SAR model fit with observed data points.

Parameters:

Name Type Description Default
fit SARFit

A fitted SAR model.

required
ax Axes

Axes to plot on. If None, creates a new figure.

None
log bool

If True, use log-log axes.

False
scatter_kw dict

Extra keyword arguments passed to ax.scatter() for the observed data points.

None
line_kw dict

Extra keyword arguments passed to ax.plot() for the fitted curve.

None

Returns:

Type Description
Axes

plot_multi

sars.plot_multi

plot_multi(multi_fit: MultiSARFit, top_n: int = 5, ax: Axes | None = None, scatter_kw: dict | None = None, line_kw: dict | None = None) -> plt.Axes

Plot the top N models from a multi-model fit.

Parameters:

Name Type Description Default
multi_fit MultiSARFit

Result of sar_multi().

required
top_n int

Number of top models (by AICc) to display.

5
ax Axes

Axes to plot on. If None, creates a new figure.

None
scatter_kw dict

Extra keyword arguments passed to ax.scatter() for the observed data points.

None
line_kw dict

Extra keyword arguments passed to ax.plot() for each fitted curve. Per-model color and label are set automatically but can be overridden.

None

Returns:

Type Description
Axes

plot_average

sars.plot_average

plot_average(averaged: AveragedSAR, ci: bool = True, boot: BootstrappedCI | None = None, ax: Axes | None = None, scatter_kw: dict | None = None, line_kw: dict | None = None, fill_kw: dict | None = None) -> plt.Axes

Plot the model-averaged SAR prediction.

Parameters:

Name Type Description Default
averaged AveragedSAR

Result of sar_average().

required
ci bool

If True and boot is provided, shade the confidence interval.

True
boot BootstrappedCI

Bootstrap confidence intervals from bootstrap_ci().

None
ax Axes

Axes to plot on. If None, creates a new figure.

None
scatter_kw dict

Extra keyword arguments passed to ax.scatter() for the observed data points.

None
line_kw dict

Extra keyword arguments passed to ax.plot() for the averaged curve.

None
fill_kw dict

Extra keyword arguments passed to ax.fill_between() for the confidence band.

None

Returns:

Type Description
Axes

plot_residuals

sars.plot_residuals

plot_residuals(fit: SARFit, ax: Axes | None = None, scatter_kw: dict | None = None) -> plt.Axes

Plot residuals vs fitted values for a SAR model fit.

Parameters:

Name Type Description Default
fit SARFit

A fitted SAR model.

required
ax Axes

Axes to plot on. If None, creates a new figure.

None
scatter_kw dict

Extra keyword arguments passed to ax.scatter() for the residual points.

None

Returns:

Type Description
Axes