具有最佳拟合线的Python 2.7概率直方图不会被绘制

时间:2018-03-22 17:29:05

标签: python matplotlib histogram

我正在尝试使用此代码从一长串概率中绘制直方图:

#create a histogram showing the probability distribution for the triangles
n, bins, patches=plt.hist([prob_long], bins=[0.36,0.365,0.37,0.375,0.38,0.385,0.39,0.395,0.40,0.405,0.41,0.415,0.42,0.425,0.43,0.435,0.44,0.445,0.45,0.455,0.46,0.465,0.47,0.475,0.48,0.485,0.49,0.495,0.5], normed=(True), facecolor='orange', alpha=0.75, ec='black')

#plot a line of best fit
(mu,sigma)=norm.fit(prob_long)
y=mlab.normpdf( bins, mu, sigma)
l=plt.plot(bins, y, 'r--', linewidth=1)

plt.xlabel('Probabilities')
plt.ylabel('Frequency')
plt.title("""Histogram of the probability distribution of the longest side 
of Pythagorean triples""")
plt.xlim([0.35,0.50])
plt.grid(True)
plt.show()

我首先使用了箱子的设定值,但它只给了我一个柱状图,所以我自己输入了值。现在它给了我各种概率,但由于我不知道的原因,频率都是200。这是我得到的直方图的图片:

Here

0 个答案:

没有答案