This is a known issue with the contouring code.  It's borrowed from an 
earlier plotting package called GIST, and assumes that the renderer can 
not handle compound polygons (for example, donut-shaped, with both an 
inner and outer edge).  So instead, it draws "cuts" that go from the 
inner to the outer edge.  When anti-aliasing is turned on, there is a 
slight overlap or "drawing twice" along this edge which creates what 
looks like a line.  Unfortunately, this can't be remedied by plotting 
the contour fills and then plotting the contour edges over top (as is 
done is contourf_demo.py).

As of matplotlib 0.98.x, matplotlib itself can handle compound paths, so 
we no longer need the cuts.  I've made a few attempts at updating the 
contouring code to avoid them, but got nowhere.  The contouring code is 
very opaque, almost magical code, and most who've dared to go in have 
barely made it out alive... ;)  That said, a fresh pair of eyes may have 
what it takes...

As for a workaround, you could render your contour as opaque, save that 
out as an image and read it back in.  The code to do that won't be 
pretty, but it just might work.

Cheers,
Mike

kippertoffee wrote:
> Hello,
>
> I am attempting to overlay a filled contour over a custom image.
>
> I have managed to get something basic working, but i have encountered a
> problem:
>
> When the contourf plot is set to semi-transparent there are visible lines
> joining the bottom of the plot and the filled contour edges. I have attached
> an image of the plot.
>
> http://img232.imageshack.us/my.php?image=spambs6.png spam.png 
>
> The code i have used is below; please bear in mind I am not a programmer, so
> if the code seems botched, that's because it is.
>
> ###############################
>
> import matplotlib.pyplot as plt
> from pylab import *
> try:
>     import Image
> except ImportError, exc:
>     raise SystemExit("PIL must be installed to run this example")
>
> lena = Image.open('lena.jpg')
> dpi = rcParams['figure.dpi']
> figsize = lena.size[0]/dpi, lena.size[1]/dpi
>
> fig = plt.figure(figsize=figsize)
> #fig.patch.set_alpha(0.5)
> ax = fig.add_subplot(111)
> #ax.patch.set_alpha(0.5)
>
> ax.imshow(lena, origin='lower')
>
> ax.contourf(z2,[10,15,20,25,30,35,40,45,50,55,60,65],alpha=0.7)
> show()
> ############################
>
>
> Can anyone help me with this problem?
>
> Thanks for reading,
> Pete.
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to