Thanks, Paul! A bit of tweaking in my actual app but it now works beautifully!

On 18/01/2011, at 4:08 PM, Paul Ivanov wrote:

> Tim Burgess, on 2011-01-18 13:32,  wrote:
>> I'm generating images that I want to use as overlays in Google
>> Earth. Thus, I would like the masked portion of the numpy
>> arrays I am using to appear as transparent.  However, I seem to
>> consistently get white instead of a transparent point.
>> 
>> To clarify the issue, I wrote this short piece of code. I am
>> setting both the figure background to transaprent and the
>> masked value to transparent but I get white.
>> 
>> I have pulled the current svn code and built matplotlib. I get
>> the same issue. 
>> 
>> from numpy import ma
>> import matplotlib.pyplot as plt
>> from pylab import colorbar, imshow, show, cm
>> 
>> 
>> def main():
>>  a = ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]])
>>  fig = plt.figure()
>>  fig.patch.set_alpha(0.0)
>>  cmap = cm.jet
>>  cmap.set_bad(alpha=0.0)
>>  imshow(a, interpolation='nearest', cmap=cmap)
>>  colorbar()
>>  show()
> 
> Hi Tim,
> 
> sorry to hear of your troubles - add these two lines to get your
> desired effect:
> 
>  ax = plt.gca()
>  ax.patch.set_alpha(0.0)
> 
> The figure has a patch associated with it, but so does each axes 
> subplot, which is what you were seeing through the transparent
> portion of your masked array image.
> 
> best,
> -- 
> Paul Ivanov
> 314 address only used for lists,  off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand 
> malware threats, the impact they can have on your business, and how you 
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl_______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to