-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plt.arrow start and end locations are wrong #12768
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
Comments
The feature you're looking for, namely the arrow starting from the start coordinates and the arrow tip ending at the end coordinates, is available via the
option.
Are you asking for the default Concerning the matplotlib/lib/matplotlib/patches.py Lines 1270 to 1271 in 4dbbd22
A usecase is seen in this example, where two arrows below one another, and shifted by half a head length, result in a picture like this: I do have the feeling that this might be about the only usecase of this; and even then it's questionable in how far this needs to be an argument to the function. Since I do however agree that the docstring is not useful at all. It might be best to just describe what the argument does,
I'm for now adding this issue to the list of things to consider for a tutorial about arrows (#11350). |
Not sure how I missed Indeed I think the default
I think that covers most use cases that arrows are used for.. So yea the only thing that's left is clearing up the doc for On another note, the use case above doesn't require that kwarg. With the default |
Well,
or
Admitedly, the API for those ones is not too clear either. But they would at least cover the above mentionned usecases. |
Using Meanwhile its matplotlib version 3.5.1 and the arrows still seem to be off: import numpy as np
import matplotlib.pyplot as plt
Z = np.random.random((50,50))
fig, ax = plt.subplots(figsize=(5.9,5.9))
im = ax.imshow(Z, origin='lower', cmap='coolwarm')
ax.hlines( 10 , 0, Z.shape[0]-1, color='black', ls='-', lw=1, alpha=.3)
ax.hlines( 40 , 0, Z.shape[0]-1, color='black', ls='-', lw=1, alpha=.3)
ax.arrow( 10, 10, 0, 30, color='white', head_width=1, length_includes_head=True)
ax.quiver(20, 10, 0, 30, angles='xy', scale_units='xy', scale=1)
ax.grid(visible=False)
fig.savefig('arrows.jpg', dpi=300) The head overshoots considerably ... (white: ... and the tail is actually off as well. EDIT Setting |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Bug report
Bug summary
When I draw an arrow from a point
(x, y)
with offset(dx, dy)
, then I expect the arrow to start at (x, y) and point to(x+dx, y+dy)
. But that's not what happens.Code for reproduction
Actual outcome
With
head_starts_at_zero=False
the arrow is longer than specified by thehead_length
(possibly intended)With
head_starts_at_zero=True
the arrow is the same length as before but moved along its direction by an arbitrary distance (possibly thehead_width
).Expected outcome
The default option should be to have the arrow start from the start coordinates and the arrow tip ending at the end coordinates. It might be nice to also have the option where the base of the arrow is at the end coordinates and the arrow head goes further (like the upper example in the plot).
Besides this feature working wrong, the documentation is unclear, which made it hard for me to find this bug:
What's "coordinate 0" here?
Might be better to write:
if that's the intended behaviour.
Matplotlib version
print(matplotlib.get_backend())
): Qt5AggEnvironment built from the Anaconda default channel.
The text was updated successfully, but these errors were encountered: