SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Darren D. <dsd...@gm...> - 2009年03月25日 16:29:25
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 999999. 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
From: Eric F. <ef...@ha...> - 2009年03月25日 19:03:05
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 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.
Eric
> 
> Thanks,
> Darren
From: Darren D. <dsd...@gm...> - 2009年03月25日 19:56:04
On Wed, Mar 25, 2009 at 3:02 PM, Eric Firing <ef...@ha...> 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 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().
>
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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /