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

Fix array alpha to multiply (not replace) existing RGBA alpha#30795

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

Open
FazeelUsmani wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromFazeelUsmani:fix-rgb-array-alpha-26092

Conversation

@FazeelUsmani
Copy link
Contributor

@FazeelUsmaniFazeelUsmani commentedNov 28, 2025
edited
Loading

Closes#26092

This fix makes array alpha behavior consistent with scalar alpha behavior for RGBA images. Now both scalar and array alpha values multiply with the existing alpha channel rather than replacing it.

What is the reasoning for this implementation?

  • For RGB images (no existing alpha): array alpha is used directly as the alpha channel (unchanged behavior)
  • For RGBA images (has existing alpha): array alpha now multiplies with existing alpha (previously it replaced it)

This matches the existing scalar alpha behavior and provides more intuitive compositing.

Example

  import numpy as np  import matplotlib.pyplot as plt  # RGBA image with 50% alpha  rgba = np.zeros((10, 10, 4), dtype=np.float32)  rgba[:, :, 0] = 1.0  # Red  rgba[:, :, 3] = 0.5  # 50% alpha  # Array alpha  alpha_arr = np.ones((10, 10))  alpha_arr[:5] = 0.5  # Before: top=0.5, bottom=1.0 (replaced)  # After:  top=0.25, bottom=0.5 (multiplied)  plt.imshow(rgba, alpha=alpha_arr)

PR checklist

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

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: alpha array-type not working with RGB image in imshow()

1 participant

@FazeelUsmani

[8]ページ先頭

©2009-2025 Movatter.jp