Skip to content

Unexpected behaviour of imshow default interpolation #19838

Closed
@Trel725

Description

@Trel725

Bug report

Bug summary

Artifacts appear when plotting periodic data with discontinuities, i.e. something like x mod 1.0
The bug appears at when render resolution is relatively small comparing to the real resolution of the data (downsampling problem?).

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

xx, yy = np.meshgrid(np.linspace(-5, 5, 201), np.linspace(-5, 5, 201))
psi = xx % 1.0

plt.figure()
plt.imshow(psi, cmap="twilight")
plt.savefig("small.png", dpi=100)
plt.savefig("large.png", dpi=200)

Outcome

alt text alt text

(large.png, small.png)

Matplotlib version

The issue is repeatable locally and in CoLab:

  • Operating system: Linux
  • Matplotlib version: 3.3.3, 3.2.2
  • Matplotlib backend (): TkAgg, ipykernel.pylab.backend_inline
  • Python version: 3.8.5, 3.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions