Repository navigation
[BUG] Fix alpha bug on 3D PathCollection plots. - #25478
Conversation
There was a problem hiding this comment.
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 |
| 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.
Are we sure this will never get an RGB (vs RGBA) array?
There was a problem hiding this comment.
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? |
|
Code looks good but still need to add a test to cover this. |
|
I took the liberty of finishing up this PR since there hasn't been action on it since January. A few things to note:
The commit history here is a bit messy so should squash merge. |
|
This is ready for review |
I just noticed this; is this something we need to ensure is fixed for 3.11? |
|
Rebased to fix the docs errors |
…478-on-v3.11.x Backport PR #25478 on branch v3.11.x ([BUG] Fix alpha bug on 3D PathCollection plots.)



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
pytestpasses)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.rstornext_api_changes/README.rst