Matplotlib Hist TypeError

时间:2017-06-09 15:47:18

标签: python matplotlib histogram jupyter-notebook

我在Jupyter Notebook(Python 2.7.5)中有以下代码:

import matplotlib.pyplot as plt
%matplotlib inline
plt.hist([1,2,3,4])

当我运行它时,我收到以下错误:

TypeError Traceback (most recent call last)
<ipython-input-6-03f4be6ff26b> in <module>()
----> 1 plt.hist([1,2,3,4])

System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.pyc in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, hold, **kwargs)
   2339         ax.hold(hold)
   2340     try:
-> 2341         ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
   2342         draw_if_interactive()
   2343     finally:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.pyc in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
   7734             # this will automatically overwrite bins,
   7735             # so that each histogram uses the same bins
-> 7736             m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
   7737             if normed:
   7738                 db = np.diff(bins)

TypeError: histogram() got an unexpected keyword argument 'new'

其他类型的图(例如散点图)在笔记本中工作正常。有没有人遇到此错误?感谢。

更新:Numpy版本为1.10.4,matplotlib版本为1.1.1。

0 个答案:

没有答案