Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
imsave/imshow and cmaps #844
Originally posted to the matplotlib-devel mailing list.
Thanks to a patch a bit while back for ListedColormap that allowed for alphas to be given, I should now be able to use imshow() and imsave() with colormaps. However, I find that the results are not correct. Particularly, the alpha values seem to be assigned incorrectly.
produces an incorrect result while
produces a correct result.
Here is an example code to replicate the bug in master.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
The problem is that what you want is direct indexing into the colormap, and to get that in a ScalarMappable, you need to specify the norm as a NoNorm instance. Change your first call to imshow to:
from matplotlib.colors import NoNorm ax.imshow(d, cmap=cm, norm=NoNorm(), interpolation='none'
and everything will be fine.