{{ message }}
Conversation
When passing an array alpha to imshow() with an RGBA image, the alpha values now multiply with the existing alpha channel rather than replacing it. This makes array alpha behavior consistent with scalar alpha behavior, which already multiplied with the existing alpha. For RGB images, array alpha continues to be used directly as the alpha channel since there is no pre-existing alpha to blend with. Closes matplotlib#26092 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Closes #26092
imshow()with an RGBA image, the alpha values now multiply with the existing alpha channel instead of replacing itThe fix is in
_ImageBase._make_image()inlib/matplotlib/image.py. Previously, the array alpha code path unconditionally replaced the alpha channel withA = np.dstack([A[..., :3], alpha]). Now it distinguishes between RGB (use alpha directly) and RGBA (multiplyA[..., 3] * alpha).Before (RGBA + array alpha replaces):
After (RGBA + array alpha multiplies):
Test plan
test_image_array_alpha_rgb- verifies RGB images with array alpha produce same result as manually constructed RGBAtest_image_array_alpha_rgba- verifies RGBA images with array alpha multiply the existing alpha channeltest_imshow_multi_drawparametrization to verify original array is not modifiedtest_interpolation_stage_rgba_respects_alpha_paramreference to expect multiplied alpha instead of replaced alpha🤖 Generated with Claude Code