I am trying to modify an existing bit of python code that displays a heatmap of values with np.histogram2d. I draw several of them, and I want the y axis and color range to be comparable between them. I learned how to manually install y_limit, but now I would like the color range to also be fixed. The following is a snippet of code:
hist,xedges,yedges = np.histogram2d(x,y, bins=[20, 50], range=[ [0, 100.0], [0, y_limit] ])
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1] ]
im = ax.imshow(hist.T,extent=extent,interpolation='nearest',origin='lower', aspect='auto')
im.set_cmap('gist_heat_r')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", "5%", pad="3%")
ax.figure.colorbar(im, cax=cax)
ax.set_title(d['name'] + ' foo')
ax.set_xlabel("bar")
ax.set_ylabel("coverage")
And an example showing different color ranges, where one goes from 0 to above 2800 and the other from 0 to 2400. I would like to be able to set the color range to a fixed maximum, for example. 3000 for both. Any ideas?


EDITED: Permitted with vminand vmax.
source
share