-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix depth shading on 3D scatterplots #29287
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
Fix depth shading on 3D scatterplots #29287
Conversation
eea5a8f
to
d90a631
Compare
@@ -483,13 +481,13 @@ def test_scatter3d_modification(fig_ref, fig_test): | |||
depthshade=False, s=75, linewidths=3) | |||
|
|||
|
|||
@pytest.mark.parametrize('depthshade', [True, False]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new depthshade behavior applies depth shading for each Patch3DCollection
. Since we are splitting this reference image into 4x scatter commands, it will have different depth shading than the single 1x scatter command for the test image.
I think this per-collection depth shading makes the most sense. The alternative would be to apply depth shading based on a fixed distance from the camera, which would give undesirable transparency to equal-distance points near the far clipping plane of the camera. Perhaps that is more intuitive for some people? But IMO the depth shading is a visual cue to help distinguish between points, so the absolute shading should be as opaque as possible, and the transparency only applied to show relative shading.
The middle ground would be to track all the patches in the scene and apply depth shading based on all the Patch3DCollection
s collectively, but I think that's probably hard to handle internally.
The original PR which added this test (#18293) was only concerned with the depthshading=False
case, so I don't think we lose much by removing the True
case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
227fc6d
to
6ce1a1a
Compare
73d3d1b
to
987ac55
Compare
b5b15a0
to
c210aac
Compare
This is good to go |
31816fd
to
f580423
Compare
AppVeyor failure is unrelated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I think there should be .. versionadded:: 3 11
where there are new arguments added (on public methods), but feel free to self-merge once those are added.
This update changes the depthscale behavior from the original Normalize method to an improved version that behaves well even when points are closely spaced. Update art3d.py Fixed line lengths, added handling of zero-length datasets when computing the data scale. Updated art3d.py per feedback Renamed get_data_scale and dscl to indicate that they are private, added description of function's purpose, and replaced np.power with np.sqrt. Update art3d.py Forgot this portion of the update earlier. Fixes the alpha draw order flipping as the point depth inverts even though the alpha should not change per point. Update art3d.py per reviewer feedback Only one dataset of (X, Y, Z) needs to be checked for zero length assuming all have the same length. Instead of using a small constant in the denominator it's cleaner to just check for '_dscl==0' and return ones instead. This applies for datasets with no datapoints, all the same datapoint such that no scale can be estimated. Update art3d.py per reviewer feedback Fixed some word wrapping, made get_data_scale more compact, replaced _dscl with the more descriptive _data_scale, removed redundant comments, added clearer comments for implementation of shading modes
Added kwargs for depth-shading Create depthshading_improvement.rst Update art3d.py formatting Update axes3d.py formatting Update depthshading_improvement.rst formatting
Remove legacy and inverted depth shade options Remove depthshade getters getter make depthshade_minalpha kwarg only kwarg order getter Update image test failures Linting fix masked scatter depth shading removed depthshade check fix tests Fix build warning
Co-authored-by: Elliott Sales de Andrade <[email protected]> Docstrings and typos Code review updates varname varname
f580423
to
73b3b08
Compare
Rebase conflict was negligible and I added those versionadded tags. CI looks good so merging! |
PR summary
Replaces #23085, which was orphaned
Closes #22861
This PR has a few changes:
dephshade_minalpha
to control the minimum opacity of the depthshading.depthshade
anddepthshade_minalpha
arguments are now controlled with rcparams.The commits are broken up by authorship so please don't squash when merging.
PR checklist