[matplotlib-devel] question about imshow's support for masked arrays

2009-03-25 Thread Darren Dale
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

a=ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]], fill_value=0)
imshow(a, interpolation='nearest')
colorbar()
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
fill_value property by calling fix_invalid, and perhaps defaulting to the
min() or max() if fill_value is the default 99. What is the intended
behavior?

Relatedly, it looks like imshow and other functions like contour are badly
confused by NaNs, I thought they were supported?

Thanks,
Darren
--
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] question about imshow's support for masked arrays

2009-03-25 Thread Eric Firing
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
> 
> a=ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]], fill_value=0)
> imshow(a, interpolation='nearest')
> colorbar()
> 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 99. 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.

Eric

> 
> Thanks,
> Darren

--
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] question about imshow's support for masked arrays

2009-03-25 Thread Darren Dale
On Wed, Mar 25, 2009 at 3:02 PM, Eric Firing  wrote:

> 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
>>
>> a=ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]], fill_value=0)
>> imshow(a, interpolation='nearest')
>> colorbar()
>> 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 99. 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().
>

I was using a greyscale colormap that painted the max value white, and I
confused no paint with max value. Personally, I think black would have been
a better default, but no matter. Thank you for the clarification.


>
> 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.
>

Ok.

Darren
--
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] AxesGrid toolkit 0.1a

2009-03-25 Thread Jae-Joon Lee
Hi list,

I packaged some of python modules that I have been using  as a mpl
toolkit. They are mostly helper classes to display images more
conveniently.  Note that I put some of them in the matplotlib as
examples.

http://dl.getdropbox.com/u/178748/AxesGrid/htdocs/index.html

It consists of pure python modules, so the installation should be
straight forward.  But I guess you need the  svn version of mpl.

 > python setup.py install

While the code is currently poorly documented, and may not be suitable
for normal users, I'm releasing it in a hope that some others find
this useful. I tried to wrote a short summary of modules included.
Although it is far from complete (and written in poor english), I hope
this gives you some idea what you can do with this toolkit.

http://dl.getdropbox.com/u/178748/AxesGrid/htdocs/users/overview.html

Regards,

-JJ

--
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel