If you do not want the automatic scaling of the colormap, you can use vmin
and vmax
to set the range you prefer, like this:
plt.imshow(arr, vmin=0, vmax=255)
When showing a numpy array, matplotlib can only automatically know the range of the actual input data (not the range it was taken from), so it takes the full input range an maps it to the full output range. But if you know a different range of the input data, you can use vmin
and vmax
to specify it.