Description
Bug report
Bug summary
Something changed the behavior of masked values in colormaps. Before, masked values on a 'jet' colormap would be drawn as white (and could be set to different colors with set_bad). This is no longer the case on matplotlib 2.2.0 - the masked values are being printed out as blue, the same color as valid values, and set_bad has no effect. Verified former behavior to be working on 2.1.1 and 2.0.2.
Not sure this is an issue or expected behavior, but I couldn't find a description of this behavior change anywhere. Please close if this is expected.
Changing interpolation from gaussian to none makes no difference (the sample code was originally used for another bug)
Code for reproduction
import matplotlib.pyplot as plt
import matplotlib.colors
heatmap = [[0] * 32 for _ in range(128)]
cnt = 0
last = 1
for lvl in range(127):
if lvl % 20 < 10:
for i in range(32):
heatmap[lvl][i] = 40
else:
for i in range(32):
heatmap[lvl][i] = 0
jet = plt.get_cmap('jet')
jet.set_bad('white', 1)
plt.imshow(heatmap, origin='lower', interpolation='gaussian', aspect='auto', cmap=jet,
norm=matplotlib.colors.LogNorm())
plt.show()
Actual outcome
Expected outcome
Matplotlib version
- Operating system: Windows
- Matplotlib version: 2.2.0
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version:3.6.3
- Jupyter version (if applicable):
- Other libraries:
Installed from pip