Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug in ax.arrow() #1113

Closed
dmcdougall opened this Issue · 6 comments

3 participants

Damon McDougall Michael Droettboom Jae-Joon Lee
Damon McDougall
Collaborator

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')
fig.savefig('arrow_simple.pdf')

And here is my sample output.

Michael Droettboom
Owner

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

Damon McDougall
Collaborator

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?

Jae-Joon Lee leejjoon was assigned
Damon McDougall
Collaborator

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.

Jae-Joon Lee
Owner

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).

Damon McDougall
Collaborator

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

Damon McDougall
Collaborator

Addressed in #1278.

Damon McDougall dmcdougall closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.