热线电话:13121318867

登录
2021-03-08 阅读量: 977
照着视频敲的。运行的时候会报这个错误,提示没有normed属性

image.png
包更新了,移除了这个属性,换用下面代码即可

import matplotlib.mlab as mlab
from scipy.stats import norm

mu = 100 # 均值
sigma = 15 # 标准差
x = mu + sigma * np.random.randn(1000)

n, bins, patches = plt.hist(x, 50, density=True)
# 添加拟合曲线
y = norm.pdf(bins, mu, sigma)
plt.plot(bins, y, '--')
plt.xlabel('Smarts')
plt.ylabel('Probability density')
plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')

# 调整间距以防止ylabel被覆盖
plt.tight_layout()
plt.show()

66.7322
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子