-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[BUG] Fix alpha bug on 3D PathCollection plots. #25478
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Thanks! Can you please add a test for this as well? I think that plotting something like in the original issue and then checking that the alpha-value of the "correct" position(s) (row 10000 to 19999) of |
Test failure is related: The test: matplotlib/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py Lines 441 to 494 in 63b9b04
Looks like an interaction with |
lib/mpl_toolkits/mplot3d/art3d.py
Outdated
return mcolors.to_rgba_array(color_array, self._alpha) | ||
|
||
if self._alpha is not None: | ||
converted_alphas = color_array[:, 3] * self._alpha |
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.
Are we sure this will never get an RGB (vs RGBA) array?
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.
Hi @tacaswell. Good point, if depthshape is specified as False a RGBA type array might get passed. I put an escape clause for this case.
converted_alphas = color_array[:, 3] * self._alpha | |
return mcolors.to_rgba_array(color_array, self._alpha) |
Since |
Hi @ricmperes, a fix to scatter plot depth shading was just merged in here: #29287 I think that should resolve the test failure you were seeing. Are you still interested in working on this PR? |
Perfect, that's great! I can rebase, test and if fixed, then close the PR. Thanks! |
Hi @ricmperes, are you still interested in working on this? |
PR Summary
Quick fix of bug on treatment of alpha parameter on the mplot3d toolkit, reported in issue #25446, following @oscargus and @tacaswell directions on the issue thread.
For Patches, no changed seemed to be needed. Might need further testing since it's the same piece of code repeated:
matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
Lines 588 to 596 in 63b9b04
A script to test the fix can be found in this gist: https://gist.github.com/ricmperes/a69d876d2cf7333ae9cf713ecb25b474
Result after fix:

PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst