Bug in ax.arrow() #1113

dmcdougall opened this Issue Aug 20, 2012 · 6 comments


None yet
3 participants

dmcdougall commented Aug 20, 2012

I was playing around, trying to give a simple version of the use of arrow in an attempt to fix issue #1096, and I think I found a bug. The arrow head does no sit square with the arrow base. Below is a snippet that reproduces the bug:

from matplotlib.backends.backend_pdf import FigureCanvasPdf as fc
from matplotlib.figure import Figure

fig = Figure()
can = fc(fig)
ax = fig.add_subplot(1, 1, 1)
ax.arrow(0, 0, 0.5, 0.5, head_width=0.05, head_length=0.1, fc='k', ec='k')

And here is my sample output.


mdboom commented Aug 20, 2012

@leejjoon : Any thoughts, as one who knows the arrow code so well?


dmcdougall commented Aug 20, 2012

My guess is perhaps the shape of the arrow head is affected by the current transform, but I tried using square axes and it still looks weird to me. Does it look weird to anyone else?

@ghost ghost assigned leejjoon Aug 21, 2012


dmcdougall commented Aug 28, 2012

On setting ax.set_aspect('equal'), I see the arrow head sits square with the stem now. I guess when I made the figure square, the axes were not square because of the room needed to be made for the tick labels.

This, then, raises an interesting question: Should the arrow be squashed with the axes? Since the base and tip are decided in the method call, we know already that the arrow head will not spill over the axes boundary.


leejjoon commented Sep 2, 2012

Axes.arrow creates a simple Polygon patch. And by default the coordinates of polygon is in data transform.
So, unless axes has an aspect=1, the shape of the arrow can be incorrect. However, there is nothing much we can do within the current implementation. So, I propose we add something about this issue in the documentation and close it.

On the other hand, I think most of current issue can be solved by using annotate (http://matplotlib.sourceforge.net/users/annotations_guide.html#annotating-with-arrow).


dmcdougall commented Sep 18, 2012

@leejjoon I agree. I will open a PR with a note in the ax.arrow docstring. I think that should suffice.


dmcdougall commented Jan 26, 2013

Addressed in #1278.

@dmcdougall dmcdougall closed this Jan 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment