8000 FIX: do invalid masking in to_rgba not set_data by tacaswell · Pull Request #6070 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: do invalid masking in to_rgba not set_data #6070

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 2 commits into from

Conversation

tacaswell
Copy link
Member

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 #6069

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
@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Feb 28, 2016
@WeatherGod
Copy link
Member

A bit concerning that our test suite didn't test this? We should definitely add a test now, I would think.

@tacaswell
Copy link
Member Author

Indeed to the test, just did not have time yet and want to get feed back
that this is the right place to fix it. Making the color maps use nan/inf
as bad values natively might be a better, if more invasive, solution.

On Sun, Feb 28, 2016, 10:39 Benjamin Root notifications@github.com wrote:

A bit concerning that our test suite didn't test this? We should
definitely add a test now, I would think.


Reply to this email directly or view it on GitHub
#6070 (comment)
.

mdboom added a commit to mdboom/matplotlib that referenced this pull request Mar 2, 2016
Alternative to matplotlib#6070

This works by converting the greyscale image to an RGBA image (with the
alpha channel created correctly) prior to resizing in Agg.  This also
removes the hack (that caused problems with over/under) where we were
using negative values to indicate transparency.
@tacaswell tacaswell closed this Mar 4, 2016
@tacaswell tacaswell deleted the fix_cmap_invalid branch March 4, 2016 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0