I have a numpy 2D array and you want to create an image so that pixels corresponding to numbers that have a high value (relative to other pixels) are painted with a more intense color. For example, if the image is in gray scale, and the pixel has a value of 0.4849, and all other pixels correspond to values ββbelow 0.001, then this pixel is likely to be painted black or something close to black.
Here is an example image, an array of 28x28 and contains values ββfrom 0 to 1.
Everything I did to build this image was done using the following code:
import matplotlib.pyplot as plt im = plt.imshow(myArray, cmap='gray') plt.show()

However, for some reason this only works if the values ββare between 0 and 1. If they are on a different scale, which may contain negative numbers, then the image does not make much sense.
source share