Open tcuisset opened 1 year ago
Hi, histplot crashes when plotting histograms with a single bin, when trying to draw overflow bins.
histplot
import hist import mplhep as hep h = hist.Hist(hist.axis.Regular(1, 0, 1)) h.fill([-1, 0.5]) hep.histplot(h)
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) Cell In[17], line 1 ----> 1 hep.histplot(h) File [***/lib/python3.10/site-packages/mplhep/plot.py:532], in histplot(H, bins, yerr, w2, w2method, stack, density, binwnorm, histtype, xerr, label, sort, edges, binticks, ax, flow, **kwargs) 528 if underflow > 0.0: 529 if flow == "hint": 530 ax.plot( 531 [ --> 532 final_bins[0] - (final_bins[-3] - final_bins[2]) * 0.03, 533 final_bins[0], 534 ], 535 [0, 0], 536 **kwargs, 537 ) 538 if flow == "show": 539 ax.plot( 540 [flow_bins[1], flow_bins[2]], 541 [0, 0], 542 **kwargs, 543 ) IndexError: index -3 is out of bounds for axis 0 with size 2
Thanks for the report @tcuisset, @Ming-Yan could you take a look?
Hi @andrzejnovak @tcuisset ,thanks for pointing this out, I open a new PR to solve this issue for both 1d/2d hist
Hi,
histplot
crashes when plotting histograms with a single bin, when trying to draw overflow bins.Reproducer :
Output