in astronomy histograms are usually normalized with the bin size (so that the histogram integral is the total number of objects).
I figured out to do an histogram normalized in this way by using numpy, and I was wondering if I can do it directly with matplotlib.
A MWE of the numpy version:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import powerlaw
NBINS = 50
RANGE = [0., 1.]
DELTA = (RANGE[1]-RANGE[0])/float(NBINS)
#--------
# fake data, pretty similar to the real ones
a=1.66
XX = powerlaw.rvs(a, size=1000)
#--------
n, bins = np.histogram(XX, NBINS, normed=False,
range = RANGE)
ntot = np.sum(n)
n = np.asarray(n, dtype=float)
n/= DELTA
print 'Histogram integral = ', np.sum(n*DELTA), ' total objects = ', ntot
plt.bar(bins[:-1], n, DELTA, log=True)
plt.show()