I am graphing data from a numpy array using matplotlib imshow. However, some points have no data in them. I initialized the array using np.zeroes, so these points are dragging down the whole map. I know that none of the data will ever have a value of 0.0. Is there some way for me to tell the imshow routine to ignore these points (ie leave them white so it is clear they are empty)?
I am graphing data from a numpy array using matplotlib imshow. However, some points
Share
Have you tried instantiating your array with NaNs instead of zeros to see if matplotlib’s default will ignore the NaNs in a way that works for you? You could also try just using logical indexing to make the locations of 0 equal to NaN right before plotting:
Alternatively, you can use the NaN idea and follow this link’s advice and use NumPy masked arrays in order to plot the NaN entries as a color you prefer.
I think you could also use that link’s idea to make a masked array at the zero locations too, without going to the NaN option if you don’t like it.