-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Add fancyarrow() as a function to draw single arrows #29826
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
Hi there, FYI I've created a package dedicated to this purpose: https://github.com/JosephBARBIERDARNAL/drawarrow You can find the most relevant function doc here: https://josephbarbierdarnal.github.io/drawarrow/reference/ax_arrow/ In my opinion, as a heavy matplotlib user and someone who uses arrows a lot, I really feel that my API is close to what I would expect in "native" matplotlib ( I'm not sure my code will help you in practice but TLDR: I've created the And since you're planning to work on this, here are a few things I particularly like about my package that I think would be nice to have by default in matplotlib, which might give you some ideas:
Please let me know if you have any question, I'm particularly interested in this topic. |
Something like 90% of the arrows I draw using annotation are using the relative positioning to object support from annotation, and those transforms are currently computed in annotation rather than FancyArrowPatch. There's a proposal to factor out the annotation coordinate handling and I think it'd have to be implemented for the For simple data coordinate arrows, I think the vector proposal should be revived and we should come to some hard decisions there.
I also really wanted to be able to set the midpoint on the bezier and the coordinate system 'cause this is messy when spanning 3 coordinate systems. |
@JosephBARBIERDARNAL thanks for the input. With For arrowstyle, I believe @story645 while reasonable, I believe we can add Artist support later. I believe this is already an improvement even if we don't support artists as reference points right away:
|
That's sorta my point though - what's the advantage of adding a a |
I believe they are separate use cases:
|
I think of ConnectionPatch as the "connect things" artist, and I think it's already got the API for comprehensive coordinate support. (xref #26440) |
Ok so what is your proposal? Should |
I'm not sure it should exist, but if it does then yeah I think wrapping ConnectionPatch makes more sense if the semantics are connection oriented. Make |
Ok I yield for now. My thought was basically "let's make FancyArrowPath available as a function, so that we don't have to recommend the awkward use annotate() without text to create an arrow". That in itself is reasonable. The question arises whether additional functionality should be included. #22435 suggests a bunch of these to better support data-like arrows. OTOH we have Artist references points (as defined in annotate()) and reference points in different coordinates and Axes as defined in ConnectionPatch. I still think the distinction between data-like and annotation/decoration-like is reasonable and we should have two separate functions on that because we cannot squeeze all the above "arrow" extensions into one API. I consider vector() the potential data-like arrow API. Whereas this here is intended for the decoration-like arrow API. However, I don't have the capacity to think about the extensions in that direction right now. It might be that |
ConnectionPatch is basically a wrapper on FancyArrowPatch that handles the coordinate transforms. Which, probably would be best to keep separate if FancyArrowPatch is also gonna act as the base artist for vector (I'm not sure if Arrow or FancyArrow was decided on as the base). matplotlib/lib/matplotlib/patches.py Line 4499 in 0d11978
I don't totally disagree, I just think ax.annotate("", ...) is not the worst API and there's a lot of functionality there (ax.connect would be ax.annotate w/o the text options) and that having a clean definition for the data arrow API will help in defining the functionality for the annotation arrows. |
Problem
Drawing arrows is currently a mess.
ax.arrow()
which uses a fundamentally broken transformation, typically resulting in skewed arrows.arrow()
with a more generalvector()
method Vector #22435ax.annotate()
with an empty text.I feel (3.) is quite complicated if you just want to draw an arrow between two points. I therefore suggest to add a method
ax.fancyarrow()
to replace (3.). It's basically a wrapper for creating a FancyArrowPatchRationale:
vector()
so that it does not overlap with a potential introduction ofvector()
laterfancyarrow
is a bit ... fancy, but we cannot usearrow
and since this returns a FancyArrowPatch,fancyarrow
seems the best viable name.The text was updated successfully, but these errors were encountered: