8000 [Bug]: zooming in on contour plot gives false extra contour lines · Issue #21300 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: zooming in on contour plot gives false extra contour lines #21300
Closed
@nschloe

Description

@nschloe

Bug summary

When zooming in on a plt.contour plot, mpl sometimes generates extra false contour lines.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

# prepare the data
delta = 0.025
x = np.arange(-1.0, 1.0, delta)
y = np.arange(-1.0, 1.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-(X ** 2) - Y ** 2)
Z2 = np.exp(-((X - 1) ** 2) - (Y - 1) ** 2)
Z = (Z1 - Z2) * 2

# the actual plotti
plt.contour(X, Y, Z, levels=[1.1], colors="red")

plt.show()

Actual outcome

sc1

Zoomed in, whoops:

sc2

Expected outcome

sc3

Operating system

Ubuntu

Matplotlib Version

3.5.0.dev1603+gec126b0175

Matplotlib Backend

Qt5Agg

Python version

3.9.7

Jupyter version

No response

Other libraries

No response

Installation

pip

Conda channel

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0