What is the easiest way to display an array with only very few different values as an image plot, e.g. with imshow
from matplotlib.pyplot
, assigning fixed colors to each of the values that show up in the array? For instance, if the array contained only the binary values 0 and 1, I would like to be able to draw all value-0-pixels in yellow and all value-1-pixels in green, say. Can this be achieved using a customised colormap or is it necessary to write a new array containing the appropriate rgb tuple for each original value?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…