我正在绘制直方图,然后将它们拼接在一起以制作动画图。有时我的数据确实是一个空列表,但出现以下代码错误:
>>> plt.hist([])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 2008, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, **kwargs)
File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 7116, in hist
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
File "/usr/lib64/python2.6/site-packages/numpy/lib/function_base.py", line 202, in histogram
range = (a.min(), a.max())
ValueError: zero-size array to ufunc.reduce without identity
如何绘制空直方图?