SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Nick F. <nv...@MI...> - 2006年07月27日 21:30:10
Dear matplotlib-users,
I'd like to report a bug in Polygon, which is crashing with an 
unhelpful error message where an exception would be appropriate. The 
problem occurs when you feed Polygon an Nx2 array instead of an N- 
length list of 2-tuples. This is on my PPC OSX system, with 
everything freshly checked out from SVN (should the matplotlib 
version still be 0.87.4?).
Versions:
In [152]: numpy.__version__
Out[152]: '1.1.2881'
In [154]: matplotlib.__version__
Out[154]: '0.87.4'
Code:
import pylab, numpy
theta = numpy.pi/4*numpy.arange(9,dtype=float)
x = numpy.cos(theta)
y = numpy.sin(theta)
# The following line works
#p = pylab.Polygon(zip(x,y))
# The following line causes a crash
p = pylab.Polygon(numpy.vstack((x,y)).T)
ax = pylab.subplot(111)
ax.add_patch(p)
pylab.show()
Output:
In [155]: run plot_polygon.py
------------------------------------------------------------------------ 
---
exceptions.TypeError Traceback (most 
recent call last)
/Users/nvf/Documents/S.M. Thesis/plot_polygon.py
 10
 11 ax = pylab.subplot(111)
---> 12 ax.add_patch(p)
 13 pylab.show() 14
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in add_patch(self, p)
 899 p.get_transform(), p.get_verts())
 900 #for x,y in xys: print x,y
--> 901 self.update_datalim(xys)
 902 self.patches.append(p)
 903
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in update_datalim(self, xys)
 913 # Otherwise, it will compute the bounds of it's 
current data
 914 # and the data in xydata
--> 915 self.dataLim.update(xys, -1)
 916
 917
TypeError: CXX : Error creating object of type N2Py5TupleE
WARNING: Failure executing file: <plot_polygon.py>
Instead of converting from crash to exception, though, would it be 
possible to make it accept an Nx2 array?
Please at least cc me in any replies, as I am not subscribed to this 
list.
Thanks,
Nick
From: Eric F. <ef...@ha...> - 2006年07月29日 22:19:00
Nick,
Thanks for the bug report. I have been making some changes to use 
numerix more consistently internally, and fixing this bug would be a 
step in that direction. I will take a look.
Eric
Nick Fotopoulos wrote:
> Dear matplotlib-users,
> 
> I'd like to report a bug in Polygon, which is crashing with an 
> unhelpful error message where an exception would be appropriate. The 
> problem occurs when you feed Polygon an Nx2 array instead of an N- 
> length list of 2-tuples. This is on my PPC OSX system, with 
> everything freshly checked out from SVN (should the matplotlib 
> version still be 0.87.4?).
> 
> Versions:
> In [152]: numpy.__version__
> Out[152]: '1.1.2881'
> In [154]: matplotlib.__version__
> Out[154]: '0.87.4'
> 
> 
> Code:
> import pylab, numpy
> 
> theta = numpy.pi/4*numpy.arange(9,dtype=float)
> 
> x = numpy.cos(theta)
> y = numpy.sin(theta)
> 
> # The following line works
> #p = pylab.Polygon(zip(x,y))
> 
> # The following line causes a crash
> p = pylab.Polygon(numpy.vstack((x,y)).T)
> 
> ax = pylab.subplot(111)
> ax.add_patch(p)
> pylab.show()
> 
> 
> Output:
> In [155]: run plot_polygon.py
> ------------------------------------------------------------------------ 
> ---
> exceptions.TypeError Traceback (most 
> recent call last)
> 
> /Users/nvf/Documents/S.M. Thesis/plot_polygon.py
> 10
> 11 ax = pylab.subplot(111)
> ---> 12 ax.add_patch(p)
> 13 pylab.show() 14
> 
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
> packages/matplotlib/axes.py in add_patch(self, p)
> 899 p.get_transform(), p.get_verts())
> 900 #for x,y in xys: print x,y
> --> 901 self.update_datalim(xys)
> 902 self.patches.append(p)
> 903
> 
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
> packages/matplotlib/axes.py in update_datalim(self, xys)
> 913 # Otherwise, it will compute the bounds of it's 
> current data
> 914 # and the data in xydata
> --> 915 self.dataLim.update(xys, -1)
> 916
> 917
> 
> TypeError: CXX : Error creating object of type N2Py5TupleE
> WARNING: Failure executing file: <plot_polygon.py>
> 
> 
> Instead of converting from crash to exception, though, would it be 
> possible to make it accept an Nx2 array?
> 
> Please at least cc me in any replies, as I am not subscribed to this 
> list.
> 
> Thanks,
> Nick
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Eric F. <ef...@ha...> - 2006年07月29日 23:47:03
Nick,
svn 2635 has a fix for this bug.
Eric
Nick Fotopoulos wrote:
> Dear matplotlib-users,
> 
> I'd like to report a bug in Polygon, which is crashing with an 
> unhelpful error message where an exception would be appropriate. The 
> problem occurs when you feed Polygon an Nx2 array instead of an N- 
> length list of 2-tuples. This is on my PPC OSX system, with 
> everything freshly checked out from SVN (should the matplotlib 
> version still be 0.87.4?).
> 
> Versions:
> In [152]: numpy.__version__
> Out[152]: '1.1.2881'
> In [154]: matplotlib.__version__
> Out[154]: '0.87.4'
> 
> 
> Code:
> import pylab, numpy
> 
> theta = numpy.pi/4*numpy.arange(9,dtype=float)
> 
> x = numpy.cos(theta)
> y = numpy.sin(theta)
> 
> # The following line works
> #p = pylab.Polygon(zip(x,y))
> 
> # The following line causes a crash
> p = pylab.Polygon(numpy.vstack((x,y)).T)
> 
> ax = pylab.subplot(111)
> ax.add_patch(p)
> pylab.show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /