8000 Axes.imshow draws invalid color at value is 0 when max of 'X' not equal to vmax · Issue #16910 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Axes.imshow draws invalid color at value is 0 when max of 'X' not equal to vmax #16910
Closed
@fifzteen

Description

@fifzteen

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.

Figure_max95

Expected outcome

if using commented data(max(data) == vmax), got output below. that is valid.
Figure_max100

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

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0