I would like to pass a colormap to a matplotlib.imshow
to plot a NxN array where each cell can only take the values -1,0 and 1.
I would like my colormap to map exactly one color (in hex code) to each value.
I just have no idea how to define a custom colormap which is not a gradation between two colors.
A solution to a very similar question was provided here. In summary ,
import matplotlib
matplotlib.colors.ListedColormap(list-of-colours)
is your friend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With