Hi all!

I'm using version 0.91.2, but by looking at the svn repository is seems 
this issue still exists.

There seems to be a bug in the getpoints() method in the YAArrow class. 
When I execute the commands

from pylab import *
annotate('Oops...', (.2, .2), (.2, .6), arrowprops=dict(width=3))
show()

(note that the x2-x1==0) I get the error:

Traceback (most recent call last):
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", 
line 331, in expose_event
     self._render_figure(self._pixmap, w, h)
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", 
line 75, in _render_figure
     FigureCanvasAgg.draw(self)
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py", 
line 358, in draw
     self.figure.draw(self.renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 
624, in draw
     for a in self.axes: a.draw(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 
1345, in draw
     a.draw(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 
1246, in draw
     self.update_positions(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 
1242, in update_positions
     **d)
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
678, in __init__
     verts = self.get_verts()
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
690, in get_verts
     xb1, yb1, xb2, yb2 = self.getpoints(x1, y1, x2, y2, k1)
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
714, in getpoints
     m = (y2-y1)/(x2-x1)
ZeroDivisionError: float division
Traceback (most recent call last):
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", 
line 331, in expose_event
     self._render_figure(self._pixmap, w, h)
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", 
line 75, in _render_figure
     FigureCanvasAgg.draw(self)
   File 
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py", 
line 358, in draw
     self.figure.draw(self.renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 
624, in draw
     for a in self.axes: a.draw(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 
1345, in draw
     a.draw(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 
1246, in draw
     self.update_positions(renderer)
   File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 
1242, in update_positions
     **d)
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
678, in __init__
     verts = self.get_verts()
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
690, in get_verts
     xb1, yb1, xb2, yb2 = self.getpoints(x1, y1, x2, y2, k1)
   File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 
714, in getpoints
     m = (y2-y1)/(x2-x1)
ZeroDivisionError: float division


It seems that the function getpoints() doesn't take care of the 
situations when the slope of the line (x1,y1,x2,y2) is zero or infinity. 
This could be solved with the simple check in the function:

if y2-y1 == 0:
        return x2, y2+k, x2, y2-k
elif x2-x1 == 0:
        return x2+k, y2, x2-k, y2

This fixes it for me.

By the way, I just found out about matplotlib, and I find it extremely 
useful! Thanks to all devs for creating this :).

Cheers,
Tuukka Verho

-------------------------------------------------------------------------
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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to