This relates to the following question:
Setting a bar chart using python
There joaquin offers installation using
(mu, sigma) = norm.fit(datos)
n, bins, patches = plt.hist(datos, 60, normed=1)
n, bins, patches = plt.hist(datos, 60, normed=1)
y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y)dd a 'best fit' line
y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y)
I also tried out the Ralph version - just bind gausses to bin data.
def plotter(lightcurves_red):
fitfunc = lambda p, x: p[0]*np.exp(-0.5*((x-p[1])/p[2])**2)
errfunc = lambda p, x, y: (y - fitfunc(p, x))
gs = gridspec.GridSpec(1,1)
ax0 = plt.subplot(gs[0])
n_red, bins_red, patches_red = ax0.hist(lightcurves_red, bins='fd', normed=True,facecolor=sns.xkcd_rgb["blood red"])
(mu_red, sigma_red) = norm.fit(lightcurves_red)
y_red = mlab.normpdf( bins_red, mu_red, sigma_red)
l_red = ax0.plot(bins_red, y_red, 'b--', linewidth=2)
init = [1.0, 0.5, 0.5]
out_red = leastsq( errfunc, init, args=( bins_red[0:len(bins_red)-1],n_red))
c_red = out_red[0]
ax0.plot(bins_red[0:len(bins_red)-1], fitfunc(c_red, bins_red[0:len(bins_red)-1]),color='black')
ax0.annotate(r'$\sigma = $' + str(abs(np.round(c_red[2],3))), xy=(0,5),xytext=(-0.075,1),fontsize=25)
plt.show()
This gives me two very different tricks. Why is this?
