Skip to content

Conversation

@AdwaithBatchu
Copy link

PR summary

closes #22571

This PR implements a method to plot a 3D arrow.

The ax.arrow3d method plots a single arrow between specified end, start points. It returns an instance of the Arrow3D class, which inherits from the FancyArrowPatch class. Additional kwargs are passed on to FancyArrowPatch to change properties of the arrow.

PR checklist

Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this! I would love to see a version of this in the library, but my strong preference is for the signature to match FancyArrowPatch.

"""
3D FancyArrowPatch object.
"""
def __init__(self, xs, ys, zs, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, xs, ys, zs, *args, **kwargs):
def __init__(self, posA, posB, *args, **kwargs):

I think the signature should match the FancyArrowPatch signature unless you have a reason not to. I implemented a rudimentary version with this signature:
https://github.com/story645/team/blob/00c7374cefb216e51b8f8350a4b5512ec1068a99/paper/figcode/nontrivial.py#L54-L64

@timhoffm
Copy link
Member

timhoffm commented Sep 5, 2025

IMO the major challenge here is semantics, scope and API design and that will entail the same topics as #29826 (comment), which lead to stalling in that thread. After all, we should have a consistent story between 2d and 3d. - I suspect to move forward here, we have to pick up the discussion from #29826.

@ksunden
Copy link
Member

ksunden commented Oct 9, 2025

While I think the more substantive discussion/change is likely the API discussion above/in the issue linked above, a small technical note that the test failure on ARM (at least, logs are gone for the azure) does appear to be a small deviation in the image, most likely due to rounding modes on the CPU architecture (RMS 0.001) so adding a tolerance may be necessary.

@AdwaithBatchu
Copy link
Author

This PR is similar to Vector #22435, and is intended to plot 'data' rather than 'annotate'.

However the Vector PR is currently inactive. It seems like this is because of the presence of another function annotate() which could be called without text to achieve similar results in 2D. However, I believe this does not apply for this PR as there is no annotate3d method.

If there are plans for Vector to be merged, I could follow the same API (mentioned in this comment) for this PR and also rename the function from arrow3d to vector3d. Now, as this used to plot 'data', it can also be changed to follow a certain color cycle by default.

I would like to know your thoughts on these @timhoffm

@timhoffm
Copy link
Member

timhoffm commented Nov 1, 2025

@AdwaithBatchu as written in #30517 (comment) I think we have to first solve the 2D case to ensure API consistency.

We currently do not have the resources and priority to work on that.

This unfortunately means working on arrow3d is blocked.

As a temporary solution, you could create an example in the 3D section of our gallery, containing arrow3d as a standalone function. So that there is documented way how to draw 3d arrows, but we don't have to set an API in stone yet or ensure coverage of edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: FancyArrow in 3D

4 participants