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
pylab image_masked is broken #6509
Comments
attn: @mdboom cmap = get_cmap('viridis')
cmap.set_over('c')
cmap.set_under('r')
fig, axs = subplots(ncols=3)
axs[0].imshow(randn(20,20), vmin=-0.5, vmax=0.5, cmap=cmap, interpolation='bilinear')
axs[1].imshow(randn(20,20), vmin=-0.5, vmax=0.5, cmap=cmap, interpolation='none')
axs[2].imshow(randn(20,20), vmin=-0.5, vmax=0.5, cmap=cmap, interpolation='nearest') |
For the second plot, BoundaryNorm is not broken, so it looks like the problem is that imshow is no longer recognizing the integer indexing into the colormap LUT. from matplotlib.colors import BoundaryNorm
bn = BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1], ncolors=256, clip=False)
xx = np.linspace(-2, 2, 100).reshape(10, 10)
fig, (ax0, ax1) = subplots(ncols=2)
ax0.pcolormesh(xx, norm=bn, cmap=cmap)
ax1.imshow(xx, norm=bn, cmap=cmap) |
It seems that which is generated off of the commit in #6581 |
I think @tacaswell's solution in #6581 is actually pretty elegant and doesn't add much runtime overhead. |
It still completely fails on BoundaryNorm and NoNorm use cases though. |
Did you see my comment in #6581 about a fix for BoundaryNorm? |
@mdboom, does image handling always go through |
Doesn't that leaves us right back where we started? Interpolating in RGBA space and all of the incorrect results that that causes? |
@mdboom, only in the case of integer colormap indexing, where interpolation other than none or nearest is not really appropriate anyway--so I don't see any real problem. It would be the same as the present case with RGBA input, right? |
I see your point. I'm sure there are some users that pass in integers representing continuous data anyway. Seems like a reasonable compromise -- if ints passed in, map to rgba first. If floats, interpolate then color map. |
To be sure it is clear: what we are talking about is the dtype after application of the norm, so the integer case is encountered only when BoundaryNorm is used (on a floating point or integer array), or NoNorm on an integer array. In other words, this is the case where the user is saying "use exactly these colors that I specify by indexing into the LUT". One could even go so far as to warn when the requested interpolation is not "none" or "nearest" in such a case, but I think that would be overkill. |
I believe this was fixed by #6581. |
It looks like the input values are getting clipped instead of registering as over and under.
With v2.x:
It should look like this, from v1.5:
The text was updated successfully, but these errors were encountered: