For me, the easiest way is to directly print masks with imshow, transfer different color palettes. The maximum and minimum number of colors are used for True and False values:
mask1=np.isnan(a) mask2=np.logical_not(mask1) plt.imshow(mask1,cmap='gray') plt.imshow(mask2,cmap='rainbow')

However, this (and other proposed approaches) also lays down False values that override previous graphs. If you want to avoid building False values, you can do this by replacing them with np.nan after converting the array to float (np.nan is of type float and cannot be contained in a boolean mask). nan values are not displayed:
mmm=mask.astype(np.float) mmm[np.where(mmm==0)]=np.nan
And I hope that I will not move on to the topic, but the same method can be used to build a different part of the data with different color maps, replacing the graph plotting command:
plt.imshow(mmm*data,cmap='rainbow')

source share