Yes.  By far the worst of these behaviors is the macosx GUI output.  I
could see the other ones just being the way it's supposed to look.
Here's a summary:

backend: macosx; path.simplify: (false|true) GUI => black borders to
drawn polygons (incl. contour region crossing lines, very bad)
http://zaneselvans.org/dropbox/contourf_backendmacosx.png

backend: agg (PNG output) path.simplify: (true|false) => somewhat
visible borders between polygons (esp. adjacent to contrasting colors)
http://zaneselvans.org/dropbox/contourf_simplifytrue.png
http://zaneselvans.org/dropbox/contourf_simplifyfalse.png

backend: pdf (PDF output) path.simplify: true => reliably visible
irregularities (but probably this is somewhat expected with SVG
output)
http://zaneselvans.org/dropbox/contourf_simplifytrue.pdf

backend: pdf (PDF output) path.simplify: false => infinitessimally
thin lines of background color visible between contour filled regions.
http://zaneselvans.org/dropbox/contourf_simplifyfalse.pdf

And here's what I used to generate them:

def broken_contourf():
    """
    Simple demonstration that filled contour plots are broken.

    Looking at the PDF and PNG output using the macosx backend, everything is
    fine.  It's only the GUI output which is for some reason outlining the
    polygons in the filled contours.

    """
    from numpy.random import uniform, seed
    from matplotlib.mlab import griddata
    import matplotlib.pyplot as plt
    import numpy as np
    # make up data.
    #npts = int(raw_input('enter # of random points to plot:'))
    seed(-1)
    npts = 200
    x = uniform(-2,2,npts)
    y = uniform(-2,2,npts)
    z = x*np.exp(-x**2-y**2)
    # define grid.
    xi = np.linspace(-2.1,2.1,100)
    yi = np.linspace(-2.1,2.1,100)
    # grid the data.
    zi = griddata(x,y,z,xi,yi)
    # contour the gridded data, plotting dots at the nonuniform data points.
    CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
    # plot data points.
    plt.title('griddata() and contourf() test')
    plt.savefig('broken_contourf.pdf')
    plt.savefig('broken_contourf.png')

On Fri, Jun 12, 2009 at 3:02 PM, Zane Selvans<z...@ideotrope.org> wrote:
> I switched back to using the macosx backend, and it turns out that the
> thin black lines surrounding the polygons (including crossing the
> filled contour regions from one closed contour to another) only get
> displayed in the GUI.  PDF and PNG output look fine.
>
> Zane
>
> On Fri, Jun 12, 2009 at 2:27 PM, Zane Selvans<z...@ideotrope.org> wrote:
>> If I set path.simplify: False, the shape of the gaps between the
>> filled polygons does change.  Instead of being irregular, it becomes
>> an infinitessimally thin gap of uniform width, allowing the (in this
>> case white) background to show through.
>>
>> In both of these cases (path.simplify: True|False), the PNG version of
>> the same figures also show representations of these gaps which are
>> identical to those which appear in the PDF (though obviously
>> pixelated), so I don't think it's something that's wrong in the vector
>> graphics code per se.
>>
>> Zane
>>
>> On Fri, Jun 12, 2009 at 11:46 AM, Michael Droettboom<md...@stsci.edu> wrote:
>>> Shot in the dark here, but what if you set the rcParam "path.simplify" to
>>> False?  There have been recent changes to that code.
>>>
>>> Also, since the Agg backend doesn't have an associated GUI, you need to use
>>> the savefig() command and provide a filename, rather than using show().
>>>
>>> Cheers,
>>> Mike
>>>
>>> Zane Selvans wrote:
>>>>
>>>> Um, yeah.  So my response got bounced because of the attachment.  Take 2:
>>>>
>>>> For some reason my script bombed when I switched to the Agg backend,
>>>> trying to display to the screen (it said Figure has no method show())
>>>>
>>>> So I output the plot as both a PDF and a PNG (still having backend:
>>>> agg in my rcfile) and in both of those cases, irregular gaps are
>>>> visible between the polygons making up the filled contours.  This
>>>> wasn't the case with my previously installed setup.  It looks as if
>>>> for some reason the vertices of the filled polygons are being
>>>> calculated differently from different sides of the same contour,
>>>> leading to overlap in some places, and gaps in others.  You can download
>>>> the PDF version (in which the exact geometry is much clearer).
>>>> from:
>>>>
>>>> http://zaneselvans.org/dropbox/LinDensity_Grid.pdf
>>>>
>>>> Zane
>>>>
>>>> On Fri, Jun 12, 2009 at 5:51 AM, Michael Droettboom<md...@stsci.edu>
>>>> wrote:
>>>>
>>>>>
>>>>> So you see this behavior if you switch to the Agg backend?  That's the
>>>>> backend used to generate the images in the gallery.  If there's a
>>>>> difference
>>>>> there, that would seem to suggest some tweaking of the macosx backend
>>>>> (which
>>>>> is still relatively new) is in order.
>>>>>
>>>>> Mike
>>>>>
>>>>> Zane Selvans wrote:
>>>>>
>>>>>>
>>>>>> I just installed the latest SciPy Superpack in order to get access to
>>>>>> the scipy.spatial.KDTree class, and discovered that for some reason
>>>>>> now when I use contourf() lines get drawn at the boundaries between
>>>>>> the filled contours.  Additionally, there is always a single vertical
>>>>>> line crossing from each contour boundary to the next.  I'm guessing
>>>>>> that these are the edges of the filled polygons which are getting
>>>>>> drawn.  This behavior doesn't seem to be consistent with the
>>>>>> contourf() documentation and when I run code in griddata_demo.py it
>>>>>> doesn't come out looking like the picture in the documentation/example
>>>>>> gallery...
>>>>>>
>>>>>> Is anyone else seeing this behavior?  Is there a keyword I can use to
>>>>>> force the edges of the polygons not to get drawn?
>>>>>>
>>>>>> This is on Mac OS X 10.5.7, with
>>>>>> scipy.__version__ = 0.8.0.dev5635
>>>>>> matplotlib.__version__ = 0.98.6svn
>>>>>> numpy.__version__=1.4.0.dev6728
>>>>>>
>>>>>> As installed by superpack_2009.03.28.sh
>>>>>> from http://macinscience.org/?page_id=6
>>>>>>
>>>>>> using:
>>>>>> backend: macosx
>>>>>>
>>>>>> Cheers,
>>>>>> Zane
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Michael Droettboom
>>>>> Science Software Branch
>>>>> Operations and Engineering Division
>>>>> Space Telescope Science Institute
>>>>> Operated by AURA for NASA
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> Michael Droettboom
>>> Science Software Branch
>>> Operations and Engineering Division
>>> Space Telescope Science Institute
>>> Operated by AURA for NASA
>>>
>>>
>>
>>
>>
>> --
>> Zane A. Selvans
>> Amateur Earthling
>> http://zaneselvans.org
>> +1 303 815 6866
>>
>
>
>
> --
> Zane A. Selvans
> Amateur Earthling
> http://zaneselvans.org
> +1 303 815 6866
>



-- 
Zane A. Selvans
Amateur Earthling
http://zaneselvans.org
+1 303 815 6866

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to