I have a CSV data file that has data of the (simplified) form:
1.2, 2.2, o, s
1.7, s, 2.4, 2.9
o, 0.9, 0.1, NaN
1.4, s, 0.5, 0.9
NB: This contains the character 'o', not the number zero (0). This file is mixed with characters that indicate different types of "failed" measurements. These matrices are typically much larger than a 4x4 grid.
I would like to plot these matrices on a colour map using matplotlib
but where each failed measurement value is assigned its own colour on the plot, whilst preserving the colour range of legitimate data.
Something with logic like e.g. `
if data == 'o':
pixel_colour = 'red'
if data == 's':
pixel_colour = 'black'
if data == 'NaN':
pixel_colour = 'white'
` I have seen this helpful post (Changing colours of pixels of plt.imshow() image.) already but I can't think of how to get this to handle heterogeneous data types.