1. Do not use pgf backend
As @unutbu noted in his (unfortunately, now deleted) answer, using the pgf backend will not actually lead to the expected schedule.
Delete row
mpl.use('pgf')
will give

2. Step function
If for some reason the use of the pgf backend cannot be avoided, a workaround may be to use the step function to plot the histogram. Extract ax1.hist(...) from code and replace it with
hist, ex = np.histogram(dat, bins = bins) ax1.fill_between(bins[:-1], hist, lw=0.0, step="post")
gives

source share