Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in ax.arrow() #1113

Closed
dmcdougall opened this issue Aug 20, 2012 · 6 comments
Closed

Bug in ax.arrow() #1113

dmcdougall opened this issue Aug 20, 2012 · 6 comments
Assignees

Comments

@dmcdougall
Copy link
Member

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.

@mdboom
Copy link
Member

mdboom commented Aug 20, 2012

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

@dmcdougall
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Contributor

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
Copy link
Member Author

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

@dmcdougall
Copy link
Member Author

Addressed in #1278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants