我已經繪製Python中的直方圖,使用matplotlib,我需要y軸是概率,我無法找到如何做到這一點。例如,我希望它看起來類似於這樣http://www.mathamazement.com/images/Pre-Calculus/10_Sequences-Series-and-Summation-Notation/10_07_Probability/10-coin-toss-histogram.JPG製作柱狀圖概率的y軸,蟒蛇
這裏是我的代碼,我會在需要時
plt.figure(figsize=(10,10))
mu = np.mean(a) #mean of distribution
sigma = np.std(a) # standard deviation of distribution
n, bins,patches=plt.hist(a,bin, normed=True, facecolor='white')
y = mlab.normpdf(bins, mu, sigma)
plt.plot(bins,y,'r--')
print np.sum(n*np.diff(bins))# proved the intergal over bars is unity
plt.show()
請添加您的數據(或代碼來生成它),並添加您的情節。 –