Skip to content
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

Explicit plotorder #12744

Closed
wants to merge 3 commits into from
Closed

Conversation

jbriales
Copy link

@jbriales jbriales commented Nov 4, 2018

PR Summary

Artifacts are common in mplot3d when overlaying several 3D objects
This is stated in the official FAQ,
and there exist some related issues(e.g. this one) as well as SO questions.

The official answer is that mplot3d is not powerful enough to deal with a realistic z-order behavior, so switch to a more powerful framework instead.
In some use cases, we don't need super-realistic z-ordering, yet some control of which objects are plot over which others is important to get a nice look.
For example: My personal (current) use case was plotting some points and lines over a surface in 3D (to represent the evolution of optimization over a surface in a nice 3D figure).

The current behavior of mplot3d is to order collections and patches (set their zorder value) in terms of the minimum z as seen in the current perspective, which gives aweful results in some common scenarios (e.g. when plotting a point on top of the surface, it will often appear behind the surface rather than in front of it).
Worse yet, art3d objects silently accept a 'zorder' argument but then ignore that value in favor of the behavior explained above.
I think it should be possible to provide user-given zorder values to ensure certain objects are in front of others, and then order also in terms of the computed zmin value for the object.

I have created a quick solution that works for me, leveraging an already existing method set_sort_zpos (which by the way I couldn't see used in any other place, so I kind of assumed it had this purpose). The commits should be more-or-less self-explanatory.
There are some aspects to refine yet, e.g.

  • Catch the 'zorder' kw-argument in mplot3d objects and set the internal parameter and use it to set _sort_zpos instead. This way the zorder option would behave in a more expectable way for the user.
  • Complete PR Checklist

However, before refining those details I wanted to present the case and get some feedback on this!

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor

anntzer commented Jun 12, 2019

Milestoning as 3.2 so that either this or #14508 hopefully gets a proper review before 3.2.

@jklymak
Copy link
Member

jklymak commented Mar 27, 2021

I'm 95% sure this has been superseded, but please reopen if I'm mistaken. Thanks for the contribution!

@timhoffm
Copy link
Member

Yes, this is implemented in #14508.

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.

None yet

7 participants