suppose I have a 2D matrix of 1s and 0s and I plot it with imshow
:
import matplotlib.pyplot as plt
plt.imshow([[1,0],[0,1]])
I would get the following output
Is there an easy way to map the colours to specific values? for example the 0
to grey and the 1
to blue? I presume something like
from matplotlib.colors import ListedColormap
cm = ListedColormap(['grey', 'blue'])
plt.imshow([[1,0],[0,1]], cmap=cm)
However that misses the mapping with the values. Couldn't find anything straightforward on SO.