Skip to content

[ENH]: do_3d_projection could restore original verts order after draw() finishes #23155

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
anntzer opened this issue May 27, 2022 · 7 comments
Closed
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! New feature topic: mplot3d
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented May 27, 2022

Problem

do_3d_projection() reorders vertices of various 3D collection artists in z-depth. Once the drawing is done, it would be useful to restore back the original order, so that e.g. interactive tools (mplcursors) reporting the index of a picked collection member get the original index as set by the user (anntzer/mplcursors#49). This should be reasonably cheap to do as we can probably just stash the original arrays somewhere and restore them as attributes at the end.

In practice, this probably means adding another API like doing_3d_projection() which returns a contextmanager (or letting do_3d_projection() possibly return a contextmanager and doing a typecheck on that) and replacing the calls to do_3d_projection() to stack.enter_context(artist.doing_3d_projection()) where stack = ExitStack() is defined at the top of Axes3D.draw().

Proposed solution

No response

@tacaswell tacaswell added this to the v3.7.0 milestone May 27, 2022
@tacaswell tacaswell added Good first issue Open a pull request against these issues if there are no active ones! Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues labels May 27, 2022
@tacaswell
Copy link
Member

Tagging this as a good first issue because I think this can be done without adding any public API, but medium because you should be conversant with writing context managers and will need to read and understand the 3D artist code.

@evanandresen
Copy link

Could I work on this issue? This is my first time looking into matplotlib src and I would like to help out.

@tacaswell
Copy link
Member

Yes, unless there is an active PR the issue is fair game!

As noted above, you will need to be familiar with context managers and read/understand the 3D code which a bit complex. If you start on this and have any questions about the existing code please ask!

@QuLogic
Copy link
Member

QuLogic commented Sep 20, 2022

I did this for some cases in #18932; I should probably return to the rest.

@hukaidong
Copy link
Contributor

PR #24491 would be enough to close this issue

@tacaswell
Copy link
Member

Closed by #24491

@tacaswell
Copy link
Member

Thank you for the triage work @hukaidong !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! New feature topic: mplot3d
Projects
None yet
Development

No branches or pull requests

5 participants