-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
imshow no longer correctly handles 'bad' (nan
) values
#6069
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
Comments
It looks like new image re-sampling code loses the mask that gets added on the way into |
The way that color mapping used to work was: - mask invalid - normalize - cmap (which uses the mask information fill in 'bad' values) - interpolate The new order is: - mask invalid - interpolate (converting mask -> nan) - normalize (which passes through nan) - cmap which results in cmap seeing the `nan` which it seems to map to 0. This does the masking on the interpolated array just prior to normalizing and removes it on the way in. Fixes matplotlib#6069
Lemme know if you need help with this one. |
Fix #6069. Handle image masks correctly
Fix #6069. Handle image masks correctly
In the case of RGBA there is no color mapping. The black coming through is a bit odd. @mankoff What version of mpl and what backend are you using? |
mpl: 1.5.1 I'm not sure what you mean by "no color mapping". Is it possible to have transparent values in an RGB displayed with imshow? |
This original bug in this issue with the new image code which is only on 2.x/master (not released yet). What I mean by 'no color mapping' is that if you pass a (M, N, 3) or (M, N, 4) array to imshow it does not get run through the normalization / color mapping code path. The [0,1] -> R3 step has a mapping, plus three special colors 'over', 'under', and 'bad'. I am actually not sure what to expect for an RGB/RGBA input with nans in it. Did this used to do something different? In any case, can you make a new issue? |
Something might have gotten lost. We are using |
Contrary to my last comment, I don't think anything has been lost. Looking at v1.4.1, I don't see any indication in the code or the docstring that invalid or masked data has ever been supported for RGB or RGBA arrays. Even though they get passed through |
I think it is a useful feature that regions of NaN appear like holes when visualised by |
Can you try with 2.0.2 or provide a MWE in a new issue? I have a memory of fixing something like that recently. |
To help us understand and resolve your issue please check that you have provided
the information below.
that demonstrates the issue i.e a small piece of code which reproduces the issue
and can be run with out any other (or as few as possible) external dependencies.
Also got some user warnings
note where it used to work.
The text was updated successfully, but these errors were encountered: