我已经绘制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()
请添加您的数据(或代码来生成它),并添加您的情节。 –