Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 问:' ;;多边形';对象没有属性';标准化';内置hddm_Python_Matplotlib - Fatal编程技术网

Python 问:' ;;多边形';对象没有属性';标准化';内置hddm

Python 问:' ;;多边形';对象没有属性';标准化';内置hddm,python,matplotlib,Python,Matplotlib,当我开始在hddm模型中运行带有自身数据的示例时,我弄错了。 'Polygon'对象在hddm模型中没有属性“normed” 那么,如何使该函数“绘图后预测”工作? 我尝试了一些方法来处理它,但我没有解决这个问题。 我试图将matplotlib降级到3.2.0版本,但它不起作用。 然而,其他一些绘图函数可以工作,如绘图后分位数、绘图后验数和绘图后验数条件。 所以,我认为问题在于歌舞伎而不是matplotlib -------------------------------------------

当我开始在hddm模型中运行带有自身数据的示例时,我弄错了。
'Polygon'对象在hddm模型中没有属性“normed”

那么,如何使该函数“绘图后预测”工作?

我尝试了一些方法来处理它,但我没有解决这个问题。 我试图将matplotlib降级到3.2.0版本,但它不起作用。 然而,其他一些绘图函数可以工作,如绘图后分位数、绘图后验数和绘图后验数条件。 所以,我认为问题在于歌舞伎而不是matplotlib

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-8540e2e64635> in <module>
----> 1 m.plot_posterior_predictive()

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\hddm\models\base.py in plot_posterior_predictive(self, *args, **kwargs)
    766         if 'value_range' not in kwargs:
    767             kwargs['value_range'] = np.linspace(-5, 5, 100)
--> 768         kabuki.analyze.plot_posterior_predictive(self, *args, **kwargs)
    769 
    770     def plot_posterior_quantiles(self, *args, **kwargs):

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\kabuki\analyze.py in plot_posterior_predictive(model, plot_func, required_method, columns, save, path, figsize, format, num_subjs, **kwargs)
    558                 ax.set_title(str(bottom_node['subj_idx']))
    559 
--> 560             plot_func(bottom_node['node'], ax, **kwargs)
    561 
    562             if num_subjs is not None and i >= num_subjs:

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\kabuki\analyze.py in _plot_posterior_pdf_node(bottom_node, axis, value_range, samples, bins)
    476     # Plot data
    477     if len(bottom_node.value) != 0:
--> 478         axis.hist(bottom_node.value.values, normed=True, color='r',
    479                   range=(value_range[0], value_range[-1]), label='data',
    480                   bins=bins, histtype='step', lw=2.)

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
   1563     def inner(ax, *args, data=None, **kwargs):
   1564         if data is None:
-> 1565             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1566 
   1567         bound = new_sig.bind(ax, *args, **kwargs)

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\matplotlib\axes\_axes.py in hist(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
   6817             if patch:
   6818                 p = patch[0]
-> 6819                 p.update(kwargs)
   6820                 if lbl is not None:
   6821                     p.set_label(lbl)

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\matplotlib\artist.py in update(self, props)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\matplotlib\artist.py in <listcomp>(.0)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

D:\ProgramData\Anaconda3\envs\py39\lib\site-packages\matplotlib\artist.py in _update_property(self, k, v)
    999                 func = getattr(self, 'set_' + k, None)
   1000                 if not callable(func):
-> 1001                     raise AttributeError('{!r} object has no property {!r}'
   1002                                          .format(type(self).__name__, k))
   1003                 return func(v)

AttributeError: 'Polygon' object has no property 'normed'
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在里面
---->1 m.后测图
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\hddm\models\base.py in plot\u posterior\u predictive(self,*args,**kwargs)
766如果“值_范围”不以kwargs为单位:
767 kwargs['value_range']=np.linspace(-5,5100)
-->768歌舞伎。分析。绘图。预测(自我,*args,**kwargs)
769
770 def绘图后分位数(自身、*args、**kwargs):
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\kabuki\analyze.py in plot\u posterior\u predictive(模型、plot\u func、必选方法、列、保存、路径、figsize、格式、num\u subjects、**kwargs)
558 ax.set_title(str(底部节点['subc_idx']))
559
-->560绘图功能(底部节点['node'],ax,**kwargs)
561
562如果num_subjects不是None且i>=num_subjects:
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\kabuki\analyze.py in\u plot\u posterior\u pdf\u节点(底部节点、轴、值范围、样本、箱)
476#绘图数据
477如果len(底部节点值)!=0:
-->478 axis.hist(bottom_node.value.values,normed=True,color=r',
479范围=(值范围[0],值范围[-1]),标签=数据,
480个料仓=料仓,histtype='step',lw=2。)
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\matplotlib\\uuuu init\uuuuuu.py在内部(ax、数据、*args、**kwargs)
1563 def内部(ax,*参数,数据=无,**kwargs):
1564如果数据为无:
->1565返回函数(ax,*map(sanitize_序列,args),**kwargs)
1566
1567绑定=新的信号绑定(ax,*args,**kwargs)
hist中的D:\ProgramData\Anaconda3\envs\py39\lib\site packages\matplotlib\axes\\u axes.py(self、x、bin、range、density、weights、cumulative、bottom、histtype、align、orientation、rwidth、log、color、label、stacked、**kwargs)
6817如果修补程序:
6818 p=补丁[0]
->6819 p.update(kwargs)
6820如果lbl不是无:
6821 p.set_标签(lbl)
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\matplotlib\artist.py正在更新(self,props)
1004
1005带cbook.\u setattr\u cm(self,eventson=False):
->1006 ret=[\u更新props.items()中k,v的属性(self,k,v)]
1007
1008如果长度(ret):
D:\ProgramData\Anaconda3\envs\py39\lib\site packages\matplotlib\artist.py in(.0)
1004
1005带cbook.\u setattr\u cm(self,eventson=False):
->1006 ret=[\u更新props.items()中k,v的属性(self,k,v)]
1007
1008如果长度(ret):
属性(self、k、v)中的D:\ProgramData\Anaconda3\envs\py39\lib\site packages\matplotlib\artist.py
999 func=getattr(self,'set_uu'+k,无)
1000如果不可调用(func):
->1001 raise AttributeError(“{!r}对象没有属性{!r}”
1002.格式(类型(自身)。\uuuuu名称\uuuuuk))
1003返回函数(v)
AttributeError:“多边形”对象没有属性“normed”

我发现“歌舞伎”软件包使用了不推荐的参数“normed=true”导致的问题

所以,我们只要修改一下代码,一切都会好起来的。 在478的“analyze.py”行中,将“normed=True”转换为“density=True”,如下所示

# Plot data
    if len(bottom_node.value) != 0:
        axis.hist(bottom_node.value.values, density=True, color='r',
                  range=(value_range[0], value_range[-1]), label='data',
                  bins=bins, histtype='step', lw=2.)

您应该放置一个代码示例,允许问题被重现,您可以只留下错误来展示它所说的内容和产生错误的代码行。