How to plot a gaussian over histogram

How would I be able to plot a Gaussian on top of the histogram my code generates? Here is my code below. It works perfectly and generates a histogram but I'm struggling with adding a Gaussian curve as I've only just started using pyplot. I'm also struggling with the maths involved!


You probably want to use numpy to generate a Gaussian, and then simply plot it on the same axes. There is a good example here: Fitting a Gaussian to a histogram with MatPlotLib and Numpy - wrong Y-scaling?

If you actually want to automatically generate a fitted gaussian from the data, you probably need to use scipy curve_fit or leastsq functions to fit your data, similar to what's described here: gaussian fit with scipy.optimize.curve_fit in python with wrong results

Need Your Help

inline-table and inline-block issues in IE and FF

html css internet-explorer firefox

I have 4 inline-block divs inside a block div. As you can see they look OK in Chrome. Looks OK in Opera as well. However, when I see same div in IE and FF it looks like this: