Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Feature request] Add a way to update the position of the Arrow patch. #14217

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

Closed
davidmurray opened this issue May 14, 2019 · 5 comments · Fixed by #27692
Closed

[Feature request] Add a way to update the position of the Arrow patch. #14217

davidmurray opened this issue May 14, 2019 · 5 comments · Fixed by #27692

Comments

@davidmurray
Copy link

davidmurray commented May 14, 2019

Hi,

Currently, the arrow class doesn't let you update the coordinates after creating the patch. That is, one must remove the old patch and create a new one just to move the arrows. This seems fairly inefficient.

Would it be possible to add some setter methods to let one change the arrow position and size without recreating a new one?

The motivation for this is that removing and adding a new patch requires a full re-draw (afaik) which is slow.

Thanks!

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.0.3
  • Matplotlib backend (print(matplotlib.get_backend())): qt5agg
  • Python version: 3.7
@timhoffm timhoffm added the mentored: sprint Issues intended and suitable for sprints label Oct 3, 2019
@timhoffm
Copy link
Member

timhoffm commented Oct 3, 2019

What needs to be done:

  • The _path of the Arrow itself is stored in normalized coordinates and not modified.
  • Positioning is performed by the _patch_transform. This has to be recreated when chaning the position.
  • It's probably best to store x, y, dx, dy, width in private variables so that they can be reused for recreating the transform.

This can be used as an example to start with:

import matplotlib.pyplot as plt
from matplotlib.patches import Arrow

fig, ax = plt.subplots()
ax.plot([0, 4], [10, 0])

a = Arrow(2, 0, 0, 10)
ax.add_patch(a)

# code for modifing the arrow goes here.

plt.show()

@ImportanceOfBeingErnest
Copy link
Member

Given that the transform needs to be recreated, I would not expect updating to be any faster than removing and recreating the arrow.
Possibly, making the FancyArrowPatch more user-friendly could be of higher priority.

@timhoffm
Copy link
Member

timhoffm commented Oct 3, 2019

It seems indeed, that the use of Arrow should be discouraged or even deprecated, because it suffers from the transform distorting it. This is essentially never desired.

@timhoffm timhoffm removed the mentored: sprint Issues intended and suitable for sprints label Oct 3, 2019
@github-actions
Copy link

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!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jun 16, 2023
@davidmurray
Copy link
Author

Probably still relevant

@tacaswell tacaswell removed the status: inactive Marked by the “Stale” Github Action label Jun 16, 2023
@QuLogic QuLogic added the keep Items to be ignored by the “Stale” Github Action label Jun 19, 2023
@QuLogic QuLogic added this to the v3.9.0 milestone Feb 2, 2024
@QuLogic QuLogic removed the keep Items to be ignored by the “Stale” Github Action label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants