Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ENH] Implement dynamic clipping to axes limits for 3D plots#27349

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 4 commits intomatplotlib:mainfromscottshambaugh:3d_dynamic_masking
Oct 2, 2024

Conversation

scottshambaugh
Copy link
Contributor

@scottshambaughscottshambaugh commentedNov 20, 2023
edited
Loading

Closes#25804

PR summary

This PR introduces "dynamic clipping" of the data in 3D plots, such that data outside the axis limits is not shown. I did a deep dive into stackoverflow and found 12 separate questions asking for this sort of functionality (see that list inthis comment).

All 3D plotting functions now support theaxlim_clip keyword argument (defaultFalse), which whenTrue will clip the data to the axes view limits, hiding all data outside those bounds. This clipping will be dynamically applied in real time while panning and zooming.

Please note that if one vertex of a line segment or 3D patch is clipped, the entire segment or patch will be hidden. Not being able to show partial lines or patches such that they are "smoothly" cut off at the boundaries of the view box is a limitation of the current renderer.

What's new and new gallery example image (I'm not in love with this example, but it'll do for now):

3d_clip_to_axis_limits-1

Video of the dynamic behavior, please excuse my sluggish machine:

2023-11-25.22-47-45-1.mp4

PR checklist

@scottshambaughscottshambaughforce-pushed the3d_dynamic_masking branch 7 times, most recently from74a0810 to6bed144CompareNovember 26, 2023 05:47
@scottshambaughscottshambaugh marked this pull request as ready for reviewNovember 26, 2023 05:49
@scottshambaughscottshambaughforce-pushed the3d_dynamic_masking branch 2 times, most recently from490ad58 tob73d8dcCompareNovember 26, 2023 06:08
@scottshambaughscottshambaugh changed the titleDRAFT: Implement dynamic clipping to axes limits for 3D plots[ENH] Implement dynamic clipping to axes limits for 3D plotsNov 26, 2023
@scottshambaughscottshambaughforce-pushed the3d_dynamic_masking branch 5 times, most recently from674235d tofaf74b6CompareNovember 27, 2023 16:52
@scottshambaugh
Copy link
ContributorAuthor

Current test failures are due to minor pixel differences in the contours unrelated to this change, will keep tweaking until it passes.
image

@scottshambaugh
Copy link
ContributorAuthor

scottshambaugh commentedNov 27, 2023
edited
Loading

TODO:

@scottshambaughscottshambaugh marked this pull request as draftNovember 27, 2023 22:21
@scottshambaughscottshambaughforce-pushed the3d_dynamic_masking branch 2 times, most recently fromb2a9978 tobe117e7CompareNovember 28, 2023 03:06
@scottshambaughscottshambaugh marked this pull request as ready for reviewNovember 28, 2023 03:24
@scottshambaughscottshambaughforce-pushed the3d_dynamic_masking branch 2 times, most recently from857252a to8931e3aCompareNovember 28, 2023 05:18
@QuLogic
Copy link
Member

Not being able to show partial lines or patches such that they are "smoothly" cut off at the boundaries of the view box is a limitation of the current renderer.

I don't think that's the case; we can definitely clip partial lines or patches to the Axes. Unless you mean the 3D renderer?

In that case, you would have to do some magic to calculate the clipping path of the Axes3D box with the artist in flattened 2D space, and apply it withset_clip_path. I'm not sure if that is worth it or not.

@scottshambaugh
Copy link
ContributorAuthor

Thank you for the review@QuLogic! I believe all your comments are addressed now

@scottshambaugh
Copy link
ContributorAuthor

The docs build error is unrelated:

The version switcher "https://output.circle-artifacts.com/output/job/29bcafd2-ffe3-4f64-ba51-f8cfa5bce2b5/artifacts/0/doc/build/html/_static/switcher.json" file cannot be read due to the following error:HTTPError('404 Client Error: Not Found for url: https://output.circle-artifacts.com/output/job/29bcafd2-ffe3-4f64-ba51-f8cfa5bce2b5/artifacts/0/doc/build/html/_static/switcher.json')

@scottshambaugh
Copy link
ContributorAuthor

I think that the docs error isn't actually generic, will investigate.

@QuLogic
Copy link
Member

/home/circleci/project/lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Poly3DCollection.set:45: WARNING: py:meth reference target not found: matplotlib.collections._CollectionWithSizes.set_sizes [ref.meth]

The missing reference handler is now a bit more specific about these things, so if you've added/removed some lines in a docstring, you may have to update the line numbers in the json file to get it to skip again.

@scottshambaugh
Copy link
ContributorAuthor

scottshambaugh commentedAug 24, 2024
edited
Loading

This is a rather confusing error. It traces back to./doc/missing-references.json, which has the below section:

"matplotlib.collections._CollectionWithSizes.set_sizes": [
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.barbs:179",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.broken_barh:84",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.fill_between:120",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.fill_betweenx:120",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.hexbin:213",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.pcolor:182",
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes._axes.Axes.quiver:215",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.AsteriskPolygonCollection.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.CircleCollection.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PathCollection.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PolyCollection.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.PolyQuadMesh.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.RegularPolyCollection.set:44",
"lib/matplotlib/collections.py:docstring of matplotlib.artist.StarPolygonCollection.set:44",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.barbs:179",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.broken_barh:84",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.fill_between:120",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.fill_betweenx:120",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.hexbin:213",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.pcolor:182",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.quiver:215",
"lib/matplotlib/quiver.py:docstring of matplotlib.artist.Barbs.set:45",
"lib/matplotlib/quiver.py:docstring of matplotlib.artist.Quiver.set:45",
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Barbs:212",
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.Quiver:251",
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Path3DCollection.set:46",
"lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Poly3DCollection.set:44"
],

... butset_sizes is not in theart3d.py.Poly3DCollection docstrings so I'm not sure how to adjust the numbering. Any pointers?

I did add 3 lines to the__init__() docstring, so will try adding 3 to each of these lines.

   "lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Path3DCollection.set:46",    "lib/mpl_toolkits/mplot3d/art3d.py:docstring of matplotlib.artist.Poly3DCollection.set:44"

@QuLogic
Copy link
Member

It's not complaining aboutPoly3DCollection.__init__, butPoly3DCollection.set, which is one of the weird automatic substitutions of all possible keyword arguments, but I'm not sure which one changed. It's probably easiest to build locally withmissing_references_write_json = True and see what lines changed.

Also, I just noticed this looking at other arguments, butaxlim_clip should probably get a.. versionadded:: directive in its docs.

@scottshambaugh
Copy link
ContributorAuthor

@QuLogic I'm not seeing this error on local docs builds. Do you know of another way to track it down?

Implement dynamic clipping to axes box for 3D plotsMake axlim_clip flag keyword onlyUpdatestest imagetest image restoreImplement dynamic clipping to axes box for 3D plotsMake axlim_clip flag keyword onlyUpdatestest imagetest image restoreImplement dynamic clipping to axes box for 3D plotsMake axlim_clip flag keyword onlyUpdatestest imagetest image restoreCode review comments on 3D axlim clippingCode review comments on 3D axlim clipping
@scottshambaugh
Copy link
ContributorAuthor

scottshambaugh commentedAug 31, 2024
edited
Loading

Ok, fixed the issue withWARNING: py:meth reference target not found! For future reference, I deleted the two lines in./doc/missing-references.json, pushed and waited for CI to throw the build error, and then re-added the lines with the errored line numbers.

The remaining docs error is an instance of#28744 and is unrelated.

@QuLogic I also added in.. versionadded:: 3.10 everywhere applicable, think this is good to go now.

@QuLogicQuLogic merged commit9dceafc intomatplotlib:mainOct 2, 2024
41 of 43 checks passed
@nbfazel
Copy link

Thank you for addressing this issue!

Which version of matplotlib will incorporate the fix? My current version is 3.9.2.

@scottshambaugh
Copy link
ContributorAuthor

Hi@nbfazel, this will be out in the future 3.10 release.

@nbfazel
Copy link

Thank you!

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

@QuLogicQuLogicQuLogic left review comments

@ksundenksundenksunden approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.10.0
Development

Successfully merging this pull request may close these issues.

[Bug]: Issue with setting axis limits on 3D plots
4 participants
@scottshambaugh@QuLogic@ksunden@nbfazel

[8]ページ先頭

©2009-2025 Movatter.jp