Skip to content

[Bug]: Adding contour labels affects the shape of filled contours #31344

@williamlus

Description

Bug summary

The shape of the filled contours changes unexpectedly when I add the contour labels by calling axs[1].clabel(CS).

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.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

fig, axs = plt.subplots(2, 1)
axs[0].contourf(X, Y, Z)
CS = axs[1].contourf(X, Y, Z)
labels = axs[1].clabel(CS)
plt.show()

Actual outcome

Image

Expected outcome

Image

Additional information

No response

Operating system

No response

Matplotlib Version

0.2.0.dev53938+unknown.gd5f597d3d.g0f46f27f5

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

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