Reputation: 5618
Plotting a matrix that can contain values from 0 - 100. However, there must not be a 100 but max can be 75 or something. I want to fix the color range to 0 - 100 so that even when there's no 100 in the data, the max value would still get the same color value as in a matrix where max = 100.
I tried
cax = ax.imshow(matrix,interpolation='nearest', cmap=cm.coolwarm)
fig.colorbar(cax, ticks=[0, 100])
but no success?
Upvotes: 1
Views: 424
Reputation: 49002
Try:
cax = ax.imshow(matrix, interpolation='nearest', cmap=cm.coolwarm, vmin=0, vmax=100)
Upvotes: 2