New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infinite range for hist(histtype="step") #5221
Comments
Should the first case raise an error as-well? i.e. perhaps (Aside: there's no error in the second case in python2.x) |
I think it should. |
This should go as a bug against numpy. We delegate all of the histogram computation to them, we should not maintain significant validation on top of that. |
Actually this behavior has changed recently, probably with numpy 1.10 & matplotlib 1.5: now neither command raises an error, and both give an empty plot. |
I've brought this up in the numpy-discussion mailing list. Should we close this issue and punt it to them? |
Yes, closing this here. Please ping to have re-opened if discussions with numpy go very badly. If you end up creating an issue/PR over at numpy can you please also link to this issue? |
@lzkelley Could you please provide a reference to the topic at numpy-discussion mailing list? |
I do think it is a bug of matplotlib. from matplotlib import pylab as plt
plt.hist([1,3], range(1,2)) # success
plt.hist([1,3], range(1,3), histtype="step") # success
plt.hist([1,3], range(1,2), histtype="step") # exception UnboundLocalError Traceback (most recent call last)
<ipython-input-6-73c33d0106be> in <module>()
----> 1 plt.hist([1,3], range(1,2), histtype="step")
/disk/usr100/gentoo/usr/lib64/python2.7/site-packages/matplotlib/pyplot.pyc in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, data, **kwargs)
2956 histtype=histtype, align=align, orientation=orientation,
2957 rwidth=rwidth, log=log, color=color, label=label,
-> 2958 stacked=stacked, data=data, **kwargs)
2959 finally:
2960 ax.hold(washold)
/disk/usr100/gentoo/usr/lib64/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
1810 warnings.warn(msg % (label_namer, func.__name__),
1811 RuntimeWarning, stacklevel=2)
-> 1812 return func(ax, *args, **kwargs)
1813 pre_doc = inner.__doc__
1814 if pre_doc is None:
/disk/usr100/gentoo/usr/lib64/python2.7/site-packages/matplotlib/axes/_axes.pyc in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
6207 ymin = np.amin(m[m != 0])
6208 # filter out the 0 height bins
-> 6209 ymin = max(ymin*0.9, minimum) if not input_empty else minimum
6210 ymin = min(ymin0, ymin)
6211 self.dataLim.intervaly = (ymin, ymax)
UnboundLocalError: local variable 'ymin' referenced before assignment |
Thanks @lzkelley. This bug is not caused by infinite numbers, but histogram input failing outside of the specified range. |
@heroxbd I see - yeah, this looks like a slightly different issue - but hopefully a similar fix. That is really strange: I see that |
Obviously there's isn't much to do here other than improving the error reporting in the second case.
The text was updated successfully, but these errors were encountered: