corner.py icon indicating copy to clipboard operation
corner.py copied to clipboard

`overplot_lines` fails when the dataset is one-dimensional

Open jagerber48 opened this issue 4 months ago • 1 comments

When I call overplot_lines with a 1D dataset I get an error like

...
(.../corner/core.py#line=846), in overplot_lines(fig, xs, reverse, **kwargs)
    845 for k1 in range(K):
    846     if xs[k1] is not None:
--> 847         axes[k1, k1].axvline(xs[k1], **kwargs)
    848     for k2 in range(k1 + 1, K):
    849         if xs[k1] is not None:

TypeError: 'Axes' object is not subscriptable

For multi-dimensional data I have code that draws crosshairs on best fit points on the 2D plots and it plots confidence interval lines on the histograms at the top of each column. When I call corner plot on a 1D dataset I see the histogram. I want my code to also work to add the confidence interval lines on the histogram without needing to special case this case.

Instead of giving this exception I would prefer if overplot_lines check if the data is 1D, and if so, do nothing.

jagerber48 avatar Sep 16 '25 21:09 jagerber48

Good suggestion! A PR would be much appreciated.

dfm avatar Sep 17 '25 19:09 dfm