Skip to content

imshow interpolation generating artifacts #9961

Closed
@arthur00

Description

@arthur00

Bug report

Bug summary

When interpolating a 2D heatmap on Windows, I get colored artifacts drawn over the 'bad' points. I am using LogNorm for normalization. I suspect it has something to do with the masked values caused by having 0s in a LogNorm. I set then to white with set_bad() function. On Linux, the interpolation looks entirely different (the white areas are not interpolated) and no artifacts can be seen.

I've also tried different interpolating methods, all of them seem to create artifacts, except for nearest.

image

Zooming in creates more artifacts:
image

Zooming in to one of these artifacts, reveals this:
image

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()

Matplotlib version

  • Operating system: Windows
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions