The difference is not how the histograms are calculated, but how you built the histogram. Your array Hof np.histogramstarts with a bit 4, -200in the upper left corner of the array, but will be displayed depending on your default value origin. You can manage this using keywords origin=loweror origin=upperin plt.imshow.
origin , , x, y , , H .
, plt.hist2d(), , plt.hexbin. , numpy: H, x, y, im = ax.hist2d(...),
a = np.random.rand(100)*400 - 200
b = np.random.rand(100)*16 + 4
a[:10] = -200
b[:10] = 4
f, ax = plt.subplots(3)
ax[0].hexbin(a, b, gridsize=20, extent=[-200,200,4,20], cmap=plt.cm.binary)
H, xedges, yedges = np.histogram2d(a, b, bins=20, range=[[-200,200],[4,20]])
ax[1].imshow(H.T, interpolation='nearest', cmap=plt.cm.binary, aspect='auto',
extent=[xedges[0],xedges[-1],yedges[0],yedges[-1]], origin='lower')
ax[2].hist2d(a, b, bins=20, range=[[-200,200],[4,20]], cmap=plt.cm.binary)
