StaggeredDifferenceInDifferences.plot#

StaggeredDifferenceInDifferences.plot(*, group='posterior', hdi_prob=None, figsize=(10, 6), show=True, legend_kwargs=None)[source]#

Plot the staggered difference-in-differences event study.

Parameters:
  • group (Literal['prior', 'posterior']) – Which draw group to plot. "prior" renders a single-panel prior predictive check — the observed aggregate outcome against the prior-implied counterfactual — and requires sample_prior_predictive(); "posterior" (default) renders the event study and requires fit(). The two groups intentionally return different axes layouts.

  • hdi_prob (float | None) – Probability mass of the highest density interval shown by the error bars. Unlike most other CausalPy experiments, hdi_prob for staggered DiD is fixed during effect aggregation and stored on the result bundle. If supplied here, the value must match result.hdi_prob; otherwise a ValueError is raised. Pass None (the default) to plot using the stored value. Ignored for OLS models and for group="prior".

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

  • 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.

  • ax (list[matplotlib.axes.Axes]) – A single-element list containing the event-study axes.

Return type:

tuple[Figure, list[Axes]]