On Friday, November 25, 2011, Keith Hughitt <keith.hugh...@gmail.com> wrote:
> Hi,
> I would like to draw a contour plot on top of an image and such that any
values of the countour plot < x are made transparent.
> Here is what I am doing at the moment to handle the overplotting:
>
> from matplotlib import pyplot as plt
> fig = plt.figure()
> axes = fig.add_subplot(111)
> contour = plt.imshow(contour_data,
extent=contour_extent,cmap=contour_cmap, origin='lower', zorder=10)
> im = plt.imshow(im_data, extent=im_extent, cmap=im_cmap, origin='lower',
zorder=1)
> plt.show()
>
> Any suggestions? One thing I thought about doing is converting im_data
and contour_data from grayscale to RGBA, and setting the alpha channel to 0
for all data with value less than x, but I was hoping there might be a more
straight-forward way to handle this.
> Thanks,
> Keith
>
>

Just use a numpy masked array and it will do exactly what you want.

contour_data = np.ma.masked_array(contour_data, mask=(contour_data < 0))

Cheers!
Ben Root
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to