2021-03-08
閱讀量:
1045
照著視頻敲的。運行的時候會報這個錯誤,提示沒有normed屬性
包更新了,移除了這個屬性,換用下面代碼即可
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$')
# 調(diào)整間距以防止ylabel被覆蓋
plt.tight_layout()
plt.show()






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
0條評論
0條評論
0條評論