PiecewiseITS.plot#

PiecewiseITS.plot(*, round_to=2, ci_prob=0.94, hdi_prob=None, kind='ribbon', ci_kind='hdi', num_samples=50, figsize=(10, 10), show=True, legend_kwargs=None)[source]#

Plot the piecewise interrupted time-series results.

Parameters:
  • round_to (int | None) – Number of decimals used to round numerical results in the figure title. Defaults to 2. Use None to render raw numbers.

  • ci_prob (float) – Probability mass of the highest density interval drawn around the fitted, counterfactual, causal effect, and cumulative effect bands. Must be in (0, 1]. Ignored for OLS models. Defaults to HDI_PROB (currently 0.94).

  • hdi_prob (float | None) – Deprecated. Use ci_prob instead.

  • kind (Literal['ribbon', 'histogram', 'spaghetti']) – How posterior uncertainty is rendered for Bayesian models. Defaults to "ribbon" (mean + credible band). Ignored for OLS.

  • ci_kind (Literal['hdi', 'eti']) – Credible interval type when kind="ribbon". Defaults to "hdi".

  • num_samples (int) – Number of posterior draws to overlay when kind="spaghetti". Defaults to 50.

  • figsize (tuple[float, float]) – Width and height of the figure in inches. Defaults to (10, 10).

  • show (bool) – Whether to automatically display the plot. Defaults to True.

  • legend_kwargs (dict[str, Any] | None) – Keyword arguments to adjust legend placement and styling. Supported keys: loc, bbox_to_anchor, fontsize, frameon, title (bbox_transform is accepted alongside bbox_to_anchor). The existing legend is modified in place so that custom handles are preserved.

Returns:

  • fig (matplotlib.figure.Figure) – The figure that was created (plotnine base plus matplotlib overlays for interruption lines when Bayesian).

  • ax (list[matplotlib.axes.Axes] or numpy.ndarray) – The three axes (top: observed, fitted and counterfactual; middle: causal effect; bottom: cumulative effect).

Return type:

tuple[Figure, Axes | ndarray | list[Axes]]