Certain annotation parameters cause strange error

I encountered a strange error when trying to put some annotations on a graph. I was able to simplify it to this:

pyplot.plot([1, 2, 3, 4], [0, -1, -2, 8])
pyplot.annotate("Blah", xy=(2, 2), xytext=(-20,-20), textcoords='offset points',
                 bbox=dict(boxstyle='round,pad=0.5'),
                 arrowprops=dict(arrowstyle='fancy', connectionstyle='arc3,rad=0'))

On my system (matplotlib 1.1.0 with Python 2.6 on Windows XP), this causes a long traceback culminating in

File "C:\Program Files\Python\lib\site-packages\matplotlib\bezier.py", line 129, in find_bezier_t_intersecting_with_closedpath
     raise ValueError("the segment does not seemed to intersect with the path")

  Increasing the xytext coordinates (in absolute value), to for instance (-50, -50) works with no error, and it also works without the special bbox style. Just guessing from the error message, it looks like certain combinations of fancy patches are causing problems because the shapes don't intersect in the way the drawing code assumes they should.

  I don't see anything in the docs about such edge cases, so this looks like a bug. Judging from the way that small tweaks to the code can cause the error to disappear, I imagine it could be tricky to fix, but at the least there should probably be a warning in the docs that some kinds of anootation boxes won't work with some kinds of arrows when the text is too close to the annotated point.

  Any ideas?

Thanks.

···

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
    --author unknown

I believe I fixed this in this pull request.

https://github.com/matplotlib/matplotlib/pull/566

Unfortunately, I don't think there is a easy workaround other than not
using the "fancy" arrow style.

Regards,

-JJ

···

On Sun, Oct 30, 2011 at 1:51 PM, Brendan Barnwell <brenbarn@...1219...> wrote:

   I encountered a strange error when trying to put some annotations on

a graph. I was able to simplify it to this:

pyplot.plot([1, 2, 3, 4], [0, -1, -2, 8])
pyplot.annotate("Blah", xy=(2, 2), xytext=(-20,-20),
textcoords='offset points',
bbox=dict(boxstyle='round,pad=0.5'),
arrowprops=dict(arrowstyle='fancy',
connectionstyle='arc3,rad=0'))

On my system (matplotlib 1.1.0 with Python 2.6 on Windows XP), this
causes a long traceback culminating in

File "C:\Program Files\Python\lib\site-packages\matplotlib\bezier.py",
line 129, in find_bezier_t_intersecting_with_closedpath
raise ValueError("the segment does not seemed to intersect with
the path")

   Increasing the xytext coordinates \(in absolute value\), to for

instance (-50, -50) works with no error, and it also works without the
special bbox style. Just guessing from the error message, it looks
like certain combinations of fancy patches are causing problems
because the shapes don't intersect in the way the drawing code assumes
they should.

   I don&#39;t see anything in the docs about such edge cases, so this looks

like a bug. Judging from the way that small tweaks to the code can
cause the error to disappear, I imagine it could be tricky to fix, but
at the least there should probably be a warning in the docs that some
kinds of anootation boxes won't work with some kinds of arrows when
the text is too close to the annotated point.

   Any ideas?

Thanks.
--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown

------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook
in minutes. BlackBerry App World&#153; now supports Android&#153; Apps
for the BlackBerry&reg; PlayBook&#153;. Discover just how easy and simple
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users