I am trying to modify an existing bit of python code that plots a heatmap of values using np.histogram2d
. I am plotting several of these and I want the y-axis and the colour range to be comparable among them. I found out the way to manually set y_limit
, but now I would like the colour range to also be fixed. Code snippet below:
hist,xedges,yedges = np.histogram2d(x,y, bins=[20, 50], range=[ [0, 100.0], [0, y_limit] ])
# draw the plot
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1] ]
im = ax.imshow(hist.T,extent=extent,interpolation='nearest',origin='lower', aspect='auto')
# colormap, colorbar, labels, ect.
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 the different colour ranges, where one goes from 0 to above 2800 and the other goes from 0 to above 2400. I would like to be able to set the colour range to a fixed maximum, e.g. 3000 for both. Any ideas?
EDITED: resolved by using vmin
and vmax
.