代码:
def histogram(value_array,xlabel):
mu, sigma = np.mean(value_array), np.std(value_array)
n, bins, patches = plt.hist(value_array, 50, normed=1,
facecolor='blue',histtype = "bar", alpha=0.75)
# add a 'best fit' line
y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y, linewidth=1)
plt.axis([np.min(value_array), np.max(value_array), np.min(y),np.max(y)])
plt.grid(False)
plt.xlabel(xlabel)
plt.ylabel("pdf")
plt.show()
输出: