I need to fit a curve to my histogram. It just shows me the histogram not the curve fitted. This is my code:
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
import matplotlib.mlab as mlab
f= np.loadtxt('data Ties', unpack='False')
bins = [0,1000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000]
(mu, sigma) = norm.fit(f)
#plt.hist(f, bins=bins, histtype='bar')
plt.hist(f, bins=bins, histtype='bar', normed=True)
y = mlab.normpdf( bins, mu, sigma)
plt.plot(bins,y,'r--', linewidth=1, color='r')
plt.xlabel('Diameter (Micrometer)')
plt.ylabel('Number of Chondrules')
plt.title('Distribution of chondrules diameter')
plt.legend()
plt.grid(True)
plt.show()
It plots the fit but not in a nice way. This is a piece of my data:
168000
199300
120900
216900
200800
137800
214200
174600
48200
126500
58700
149500
47500
5600
178500
25400
163000
182000
51900
66700
90300
210600
117800
164000
215200
170000
182000
38800
72700
161200
31000
I also want to know mean and sigma.