-
Notifications
You must be signed in to change notification settings - Fork 366
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
fix imshow when image is RGBA #1906
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
be79094
fix imshow when image is RGBA
ludwigVonKoopa ed2cb80
fix pep8
ludwigVonKoopa 0183fdc
Merge branch 'master' into fix_imshow
ludwigVonKoopa e2cb44c
fix pep8 again
ludwigVonKoopa 68dbb1e
remove old prints
ludwigVonKoopa e5158e6
Update lib/cartopy/mpl/geoaxes.py
ludwigVonKoopa f8a9ea2
remove np.random in test
ludwigVonKoopa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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.
It looks like you are leaving the alpha in the kwargs now, so it will be handled by Matplotlib instead of down below when filling the alpha channel. Are there any weird interactions with showing an RGBA image with an alpha channel and specifying a 2d alpha? I guess I'm not sure what I would even expect in that case.
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.
Good question.
Before this patch, this wasn't a question as alpha kwargs was merged into the data.
matplotlib : 3.4.3
So with this 2D alpha for example, it should apply stripes :
So i checked what happens now that the alpha kwargs is simply passed to matplotlib :
matplotlib : 3.4.3
I don't see the alpha stripes.
So it looks like the 2D alpha kwargs has no impacts, as if no alpha kwargs was used.
It does nothing with cartopy, but with matplotlib too (so at least the cartopy behavior mimic matplotlib behavior?)
Which is weird because in the matplotlib documentation from imshow it is clearly stated that "If alpha is an array, the alpha blending values are applied pixel by pixel, and alpha must have the same shape as X".
SO it doesn't nothing, so do matplotlib.
Did i something wrong with matplotlib, or should i raise a ticket ?
(for info, the "problem" persist with RGBA u1 and with RGBA f4 too)
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.
Actually, before this patch I think the alpha did get converted to the data array as you mentioned (striped alpha). Which is actually not what Matplotlib does as you mention. So, we were actually deviating from Matplotlib there.
A quick look shows that the alpha 2d array only works with colormapped values on Matplotlib standard Axes. It does not apply to RGB or RGBA images. I think I agree with what Matplotlib is doing there, and I like what you've done here to force us to be more consistent with that. If someone wants a 2d alpha array, they should not be sending in RGB(A) data. (I guess RGB is a bit questionable, but I think it makes sense to keep those consistent)
In summary, I agree with what you've done here.
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.
Ok thanks