warnings.warn("The 'normed' kwarg is deprecated, and has been "

在利用Python中matplotlib.pyplot画频率分布直方图的时候,用到了以下语句

plt.hist(data,bins = 100, normed = True, color = 'steelblue', edgecolor = 'k')

编辑器出现了以下报错

C:\Users\Administrator.000\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\axes\_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density'
kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "

网上查找资料之后发现挺多人也都有这个问题,是否绘制频率分布直方图的normed用在比较早的版本中,在比较新的版本中,用normed是会warning的,改的方法也非常简单,都写在了报错里,将其改为density即可。

附上plt.hist函数的官网链接

发布了34 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_41111088/article/details/83116752