Darren Dale wrote:
I am experimenting with numpy masked arrays, and have a question about how imshow handles them:
from numpy import ma
from pylab import colorbar, imshow, show
With svn matplotlib, the missing value is treated as if identical to the maximum value. I thought imshow would instead respect the masked array's
I don't see this with my installation from svn.
fill_value property by calling fix_invalid, and perhaps defaulting to the min() or max() if fill_value is the default 999999. What is the intended behavior?
What I see with your example is a white square for the masked value; actually, it is transparent, with alpha = 0. This is the intended default; if it is masked, don't paint anything. It is set in Colormap.__init__ and can be overridden by Colormap.set_bad().
There is no intention to use the masked array fill value.
Relatedly, it looks like imshow and other functions like contour are badly confused by NaNs, I thought they were supported?
I suspect we really should run the Z inputs through masked_invalid, especially for contour. The performance hit is minimal as a fraction of the total time. I will do this for contour. imshow has to be handled more carefully, so I don't want to do it in a hurry.
One of the general cleanups needed in mpl is clarity and consistency in argument validation. Part of this is a matter of clarity about API levels; we don't want to have to do full validation and acceptance of all possible input variations at every level.