Skip to content

Place 3D contourf patches between levels #21026

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

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

dstansby
Copy link
Member

@dstansby dstansby commented Sep 9, 2021

PR Summary

When doing a contourf, each polygon represents data between two levels. When setting a z-value for these polygons in 3D, previously the lower level would be chosen. This PR changes that to set the z-value to be the midpoint of the two levels. Also adds support for extensions by linearly interpolating the midpoints of the first and last levels.

Fixes #21016

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@dstansby dstansby force-pushed the contourf-3d branch 2 times, most recently from 88106bb to f29b5be Compare September 9, 2021 12:47
@dstansby dstansby marked this pull request as ready for review September 9, 2021 12:47
@dstansby dstansby added this to the v3.5.0 milestone Sep 12, 2021
@anntzer
Copy link
Contributor

anntzer commented Sep 20, 2021

After this change (which seems otherwise correct), the topmost contour surface ends up above the axis zmax (this can be checked e.g. running examples/mplot3d/contourf3d.py and rotating until the surfaces are seen "from the side"; adding e.g. levels=3 makes the effect more visible). Probably the zmin/zmax need to be adjusted?

@dstansby
Copy link
Member Author

dstansby commented Sep 24, 2021

I've fixed the limits - it's not a very elegant solution (having to manually calculate the limits, see comments I left in the code), but it works...

@anntzer
Copy link
Contributor

anntzer commented Sep 24, 2021

Looks good to me, except for perhaps the style thing above (and modulo CI).

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

let's perhaps give @timhoffm time to re-review if he wants (or say he doesn't care :-)), as there were some changes.

@timhoffm timhoffm merged commit 3d4c52c into matplotlib:master Sep 27, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 27, 2021
QuLogic added a commit that referenced this pull request Sep 27, 2021
…026-on-v3.5.x

Backport PR #21026 on branch v3.5.x (Place 3D contourf patches between levels)
@dstansby dstansby deleted the contourf-3d branch September 28, 2021 08:09
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Oct 12, 2021
Place 3D contourf patches between levels
tacaswell pushed a commit that referenced this pull request Oct 20, 2021
Place 3D contourf patches between levels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants