2
votes

I have a 28x28 numpy ndarray that I want to print out as an image. Since it is a grayscale picture, it only has one color value per pixel. These values are scaled from -0.5 to 0.5. I use plt.imshow(array). When I do that, the image gets printed out with the jet colormap, instead of grayscale.

If I apply cmap = 'gray' I get my grayscale image, but why is the default imshow() using the jet colormap)?

1
If your question is "why is the default imshow() using the jet colormap?", you should ask it on matplotlib mailing list. - Reblochon Masque
I thought, that I had something to do with the data format, since, according to the docs, default coloring is grayscale. - farnold
That's wrong @Fritz Arnold, if you read the docs the default colormap correspond to what is defined by rc image.cmap - Alejandro

1 Answers

1
votes

To prevent matplotlib from using the "jet" colormap as default you need to modify the line corresponding to the default cmap in the matplotlibrc file, usually found in ~/.config/matplotlib/matplotlibrc:

image.cmap   : gray               # gray | jet etc...

Also, I encourage everybody to see the upcoming changes regarding styling in matplotlib 2.0