AttributeError: ‘Rectangle‘ object has no property ‘normed‘ 解决方法 matplotlib绘图
Posted 叶庭云
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AttributeError: ‘Rectangle‘ object has no property ‘normed‘ 解决方法 matplotlib绘图相关的知识,希望对你有一定的参考价值。
matplotlib数据可视化,绘制直方图时报错如下:
D:\\python\\Anaconda3\\python.exe D:/python/pycharm2020/my_program/program/matplotlib/直方图/demo1.py
Traceback (most recent call last):
File "D:/python/pycharm2020/my_program/program/matplotlib/直方图/demo1.py", line 25, in <module>
plt.hist(data, bins=40, normed=0, facecolor="blue", edgecolor="black", alpha=0.7)
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\pyplot.py", line 2605, in hist
return gca().hist(
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\__init__.py", line 1565, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\axes\\_axes.py", line 6819, in hist
p.update(kwargs)
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\artist.py", line 1006, in update
ret = [_update_property(self, k, v) for k, v in props.items()]
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\artist.py", line 1006, in <listcomp>
ret = [_update_property(self, k, v) for k, v in props.items()]
File "D:\\python\\Anaconda3\\lib\\site-packages\\matplotlib\\artist.py", line 1001, in _update_property
raise AttributeError('{!r} object has no property {!r}'
AttributeError: 'Rectangle' object has no property 'normed'
原因:matplotlib版本问题,最新版本已经没有这个属性了。normed参数替换成 density 即可。
density=True:表示的是频率直方图
density=False:表示的是频数直方图
以上是关于AttributeError: ‘Rectangle‘ object has no property ‘normed‘ 解决方法 matplotlib绘图的主要内容,如果未能解决你的问题,请参考以下文章
AttributeError: 'RDD' 对象没有属性 'show'
AttributeError:“NumpyArrayIterator”对象没有属性“类”
AttributeError:模块 'dbus' 没有属性 'lowlevel'