我试图利用“weights”属性或关键字参数生成一个直方图。但是,尽管它在过去起作用并且出现在帮助说明中,但现在它时不时地失败(见下文)。我尝试过安装和卸载Python,但它一直有相同的行为。我还从应用程序中移出了一个程序,里面有自己的pythons任务(casa.nrao.edu酒店). 在
我正在研究macos10.13.1(我想知道从10.12升级到10.13是否是主要问题)。我使用的是python2.7.14、matplotlibv2.1.1、numpy 1.13.3、ipython5.4.1(但在标准pythonshell中也是如此)。在
import numpy as np
import matplotlib.pylab as plt
tmp=np.array([1,3,5,2])
wgt=tmp*0+1
np.histogram(tmp,weigths=wgt)
# TypeError Traceback (most recent call last)
# <ipython-input-4-43a11ec135ae> in <module>()
# ----> 1 np.histogram(tmp,weigths=wgt)
# TypeError: histogram() got an unexpected keyword argument 'weigths'
plt.hist(tmp,weigths=wgt)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in hist(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, normed, hold, data, **kwargs)
# 3023 histtype=histtype, align=align, orientation=orientation,
# 3024 rwidth=rwidth, log=log, color=color, label=label,
# -> 3025 stacked=stacked, normed=normed, data=data, **kwargs)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
# 1715 warnings.warn(msg % (label_namer, func.__name__),
# 1716 RuntimeWarning, stacklevel=2)
# -> 1717 return func(ax, *args, **kwargs)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in hist(***failed resolving arguments***)
# 6347 if patch:
# 6348 p = patch[0]
# -> 6349 p.update(kwargs)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/artist.pyc in update(self, props)
# 900 try:
# 901 ret = [_update_property(self, k, v)
# --> 902 for k, v in props.items()]
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/artist.pyc in _update_property(self, k, v)
# 893 func = getattr(self, 'set_' + k, None)
# 894 if not callable(func):
# --> 895 raise AttributeError('Unknown property %s' % k)
# ...
# AttributeError: Unknown property weigths
f = plt.figure()
ax2 = f.add_subplot(111)
ax2.hist(tmp,weigths=wgt)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
# 1715 warnings.warn(msg % (label_namer, func.__name__),
# 1716 RuntimeWarning, stacklevel=2)
# -> 1717 return func(ax, *args, **kwargs)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in hist(***failed resolving arguments***)
# 6347 if patch:
# 6348 p = patch[0]
# -> 6349 p.update(kwargs)
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/artist.pyc in update(self, props)
# 900 try:
# 901 ret = [_update_property(self, k, v)
# --> 902 for k, v in props.items()]
# ...
# /Users/hugomessias/anaconda2/lib/python2.7/site-packages/matplotlib/artist.pyc in _update_property(self, k, v)
# 893 func = getattr(self, 'set_' + k, None)
# 894 if not callable(func):
# --> 895 raise AttributeError('Unknown property %s' % k)
# ...
# Unknown property weigths
但时不时,np.直方图以及plt.hist公司工作,但不是斧头图. 在
任何指导都会很有帮助的!提前谢谢你!在
目前没有回答
相关问题 更多 >
编程相关推荐