The hist command automatically generates histograms and will return the bin counts or probabilities
from matplotlib import rcParams rcParams['text.fontname'] = 'cmr10' import pylab as pl mu, sigma = 100, 15 x = mu + sigma*pl.randn(10000) # the histogram of the data n, bins, patches = pl.hist(x, 100, normed=1) # add a 'best fit' line y = pl.normpdf( bins, mu, sigma) l = pl.plot(bins, y, 'r--', linewidth=2) pl.xlim(40, 160) pl.xlabel('Smarts') pl.ylabel('P') pl.title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$')