Closed
Description
Bug report
Bug summary
Axes.imshow draws invalid color at cells which value is 0 when max value of parameter 'X' is not equal to parameter 'vmax'
Code for reproduction
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np
cmap = plt.cm.get_cmap('autumn_r')
cmap.set_under(color='lightgrey')
fig = plt.figure()
ax = fig.add_subplot()
ax.grid(which='major', color='white', linestyle='dotted', alpha=0.7)
ax.grid(which='minor', color='white', linestyle='dotted', alpha=0.5)
data = np.array([[-1, -1, -1, 0, 0, 0, 0, 43, 79, 95, 66, 1, -1, -1, -1, 0, 0, 0, 34]])
# data = np.array([[-1, -1, -1, 0, 0, 0, 0, 43, 79, 100, 66, 1, -1, -1, -1, 0, 0, 0, 34]])
im = ax.imshow(data, aspect='auto', cmap=cmap, vmin=0, vmax=100)
ax.xaxis.set_major_locator(ticker.MultipleLocator())
ax.set_yticks([0])
fig.colorbar(im)
plt.show()
Actual outcome
I expect yellow at cells 3, 4, 5, 6, 15, 16, 17. but they are grey.
Expected outcome
if using commented data(max(data) == vmax), got output below. that is valid.
Matplotlib version
- Operating system: Windows10
- Matplotlib version: 3.1.3
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.7.4
Metadata
Metadata
Assignees
Labels
https://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues