I want to plot 2d histogram using matplotlib.pyplot.hist2d. As input I have masked numpy.ma arrays. That as such works fine like this:
hist2d (arr1,arr2,cmin=1)
However if I want to normalise the arrays, so I get values always between 0 and 1, using the normed=True keyword like this
hist2d (arr1,arr2,cmin=1, normed=True)
I get errors
.../numpy/ma/core.py:3791: UserWarning: Warning: converting a masked element to nan.
warnings.warn("Warning: converting a masked element to nan.")
.../matplotlib/colorbar.py:561: RuntimeWarning: invalid value encountered in greater
inrange = (ticks > -0.001) & (ticks < 1.001)
.../matplotlib/colorbar.py:561: RuntimeWarning: invalid value encountered in less
inrange = (ticks > -0.001) & (ticks < 1.001)
.../matplotlib/colors.py:556: RuntimeWarning: invalid value encountered in less
cbook._putmask(xa, xa < 0.0, -1)
Any idea how I can get round this and still get a normalised 2d histogram?
cmin=1
: this is applied after the normalisation, and there will be no elements in the histogram, as all bin values will be lower than 1 (those values are actually set to NaN). Thus, there is nothing left to plot! – Evert Aug 15 '13 at 13:58