I am displaying arrays as image using matplotlib but my high and low end values don't always make it in the array. If my desired range is from 0-9 and I randomly generate a 5x5 array the probability that 0 or 9 will missing from the array is very likely over hundreds of samples.
Is there a way to ensure that even if my high or low value doesn't make it in to the array that matplotlib will display to full range? The end goal is to have each integer value hold the same color value and not redistribute if the number is not there.
import matplotlib.pyplot as plt
import numpy as np
import os, sys
arr = np.random.randint(0,10, size=(5, 5))
plt.imshow(arr)
for i in range(10):
arr = np.random.randint(0,10, size=(5, 5))
print(np.min(arr), np.max(arr))