You've hit one of the changed APIs in 0.98.  You can see the list of 
changed APIs here:

http://matplotlib.svn.sourceforge.net/viewvc/*checkout*/matplotlib/trunk/matplotlib/API_CHANGES

Patches no longer store lists of vertices, they store Path objects + 
Affine transforms.  So rather than "get_verts()", you can use the 
admittedly obtuse "circle.get_transform().transform(get_path().vertices)".

Note also another change is required in your script for something that 
probably only worked by accident before.  The "ax.add_patch(p)" should 
be "ax.add_collection(p)", since p is a PolyCollection.

Now -- for the other developers on this list:  We may want to add a 
.get_verts() function back to patches that does exactly what I recommend 
above.  It won't behave identically to 0.91 since it will return a 
transformed copy of the vertices, but that won't matter in all cases 
(such as this one).

We may want to add a PatchCollection class that takes a list of patches, 
so users don't have to manually take patches apart like this.  This is 
now possible because all patches are basically the same thing.  This 
would also make it easier to use an bezier-approximated Ellipse rather 
than a polygonal approximated one.

Cheers,
Mike

sidimok wrote:
> Hi everyone, 
>
> The code below was working for me as a charm, but since the new matlplotlib
> flavor 0.98, I'm getting this error message: 
>
>   
>>> AttributeError: 'CirclePolygon' object has no attribute 'get_verts' << 
>>>       
>
> Any idea?
>
> - - - - - - - - - - - - - - - - - - -
>  
> import matplotlib 
> from matplotlib.patches import CirclePolygon 
> from matplotlib.collections import PolyCollection 
> import pylab 
>
> fig=pylab.figure() 
> ax=fig.add_subplot(111) 
>
> resolution = 50 # the number of vertices 
> N = 20 
> x       = pylab.rand(N) 
> y       = pylab.rand(N) 
> radii   = 0.1*pylab.rand(N) 
> colors  = 100*pylab.rand(N) 
> verts   = [] 
> for x1,y1,r in zip(x, y, radii): 
>     circle = CirclePolygon((x1,y1), r, resolution) 
>     verts.append(circle.get_verts()) 
>     
> p = PolyCollection(verts, cmap=matplotlib.cm.jet) 
> p.set_array(pylab.array(colors)) 
> ax.add_patch(p) 
> pylab.colorbar(p) 
>
> ax.axis('equal') 
> pylab.show() 
>
>   

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


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to