plt.hist()测试

matplotlip.pyplot画图,图像标题无法显示出来

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)
mu, sigma = 100, 20
a = np.random.normal(mu,sigma,size=100)

plt.hist(a, 20,normed=1,histtype='stepfilled',facecolor='b',alpha=0.75)
plt.title('Histogram')

plt.show()

参照这个解决了https://www.freesion.com/article/46451414816/

normed=1 表示归一化?将频数转化成频率?


import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)
mu, sigma = 100, 20
a = np.random.normal(mu,sigma,size=100)

plt.hist(a, 20,histtype='stepfilled',facecolor='b',alpha=0.75)
plt.title('Histogram')

plt.show()