Skip to content

Commit 61a116d

Browse files
committed
Add histogram and spaghetti plot visualizations to plot_xY
- Add histogram visualization (2D heatmap) with global y-bins - Add spaghetti plot visualization with configurable num_samples - Add ETI (Equal-Tailed Interval) support in addition to HDI - Add comprehensive test suite for all visualization types - Maintain backward compatibility with hdi_prob parameter - Update BaseExperiment.plot() to pass through new parameters Addresses #671
1 parent 2593904 commit 61a116d

3 files changed

Lines changed: 361 additions & 4 deletions

File tree

causalpy/experiments/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def plot(
234234
kind : {"ribbon", "histogram", "spaghetti"}, optional
235235
Type of visualization. Default is "ribbon".
236236
ci_kind : {"hdi", "eti"}, optional
237-
Type of interval for ribbon plots. Default is "hdi" (matching current behavior).
237+
Type of interval for ribbon plots. Default is "hdi".
238238
ci_prob : float, optional
239239
The size of the credible interval. Default is :data:`~causalpy.constants.HDI_PROB`.
240240
num_samples : int, optional

causalpy/plot_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def plot_xY(
6262
kind : {"ribbon", "histogram", "spaghetti"}, optional
6363
Type of visualization. Default is "ribbon".
6464
ci_kind : {"hdi", "eti"}, optional
65-
Type of interval for ribbon plots. Default is "hdi" (matching current behavior).
65+
Type of interval for ribbon plots. Default is "hdi".
6666
num_samples : int, optional
6767
Number of posterior samples to plot for spaghetti visualization.
6868
Default is 50.
@@ -213,7 +213,12 @@ def _plot_histogram(
213213
plot_hdi_kwargs: dict[str, Any] | None,
214214
label: str | None,
215215
) -> tuple[list[Line2D], None]:
216-
"""2D heatmap of marginal histograms over time (posterior density vs. time)."""
216+
"""Plot histogram visualization of the posterior as a 2D heatmap.
217+
218+
Columns are time points (x), rows are y-value bins; cell values are
219+
per-time histogram counts, column-normalized for display. The posterior
220+
mean line is overlaid on top.
221+
"""
217222
if plot_hdi_kwargs is None:
218223
plot_hdi_kwargs = {}
219224

0 commit comments

Comments
 (0)