I've got a numpy array containing both np.nan (missing value) and -9999.0 (or any other arbitrary value=> non calculation possible), e.g.:
arr = array([[ 1., 2., 3., nan, 4., 4.],
[ 3., -9999.0, 2., 1., 1., 4.],
[ nan, -9999.0, 3., 1., 2., 1.]])
Now I want to plot this array with the plt.imshow
function. All NaNs shall be transparent/white and all -9999.0s shall be black, for example.
I already tried to mask the array and then use set_bad
for the colormap. Beyond that, I used vmin/vmax
and cm.set_under
.
However, in the first case it yields:
RuntimeWarning: invalid value encountered in less
when I try to mask out all values <9990.
In the second case, obviously both the NaNs and -9999.0s are interepreted as below the range of the depicted range of values.
Does anyone know help?