Skip to content

Add files via upload #30156

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

Closed
wants to merge 1 commit into from
Closed

Add files via upload #30156

wants to merge 1 commit into from

Conversation

A-n-sh
Copy link

@A-n-sh A-n-sh commented Jun 10, 2025

Three-way handler:

                # CHANGE START
                alpha = self.get_alpha()
                if alpha is not None and np.ndim(alpha) > 0:
                    # 2S array a -> pack into 4th channel
                    if A.shape[2] == 3:
                        A = np.dstack([A, alpha])
                    else:
                        A[..., 3] = alpha
                elif alpha is not None:
                    # scalar a -> broadcast or multiply existing
                    if A.shape[2] == 3:
                        A = np.dstack([A, np.full(A.shape[:2], alpha, dtype=A.dtype)])
                    else:
                        A[..., 3] = A[..., 3] * alpha
                # CHANGE END
  1. 2D mask (alpha.ndim>0)
  • RGB input -> stack mask as new 4th channel
  • RGBA input -> overwrite existing alpha channel
  1. Scalar alpha:
  • RGB input -> broadcast into full alpha channel
  • RGBA input -> multiply existing alpha channel by this value
  1. No alpha (alpha is None): leave image's own alpha untouched.

After handling, code premultiplies RGB by updated alpha and resamples-ensuring per-pixel transparency works for both grayscale and RGB images.

Standalone script for isolating issue. Creates a random 10x10 array.
Copy link

@github-actions github-actions bot left a 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 week or so, please leave a new comment below and that should bring it to our attention. 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.

@jklymak
Copy link
Member

jklymak commented Jun 10, 2025

Sorry, are you trying to report an issue? A Pull Request is probably not the right way to do that. Please open an issue instead.

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label Jun 10, 2025
@A-n-sh
Copy link
Author

A-n-sh commented Jun 10, 2025 via email

@jklymak
Copy link
Member

jklymak commented Jun 10, 2025

You didn't fix anything, you just uploaded a file that doesn't do anything.

While we think it is important for students to learn, we don't have the bandwidth to be your class teaching assistants or to walk you though how to make a proper contribution. Please ask your class instructors for help. We also have a very comprehensive development guide that you should read carefully before contributing.

@A-n-sh
Copy link
Author

A-n-sh commented Jun 10, 2025 via email

@jklymak jklymak closed this Jun 10, 2025
@jklymak
Copy link
Member

jklymak commented Jun 10, 2025

OK thanks for your interest in Matplotlib, and feel free to resubmit when you have things sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants