Skip to content

[Bug]: Changing the color of a contour plot messes up the contour lines and fill colors #31335

@smith2936

Description

@smith2936

Bug summary

If we change the color of a contour set to black by calling CS.set_color('k'), the lines and fill colors are messed up, and the colors of contour labels are not updated to black correspondingly.

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, ax = plt.subplots()
CS = ax.contour(X, Y, Z)
ax.clabel(CS, fontsize=10)
CS.set_color('k') # mess up the contour lines
plt.show()

Actual outcome

Image

Expected outcome

Image

Additional information

No response

Operating system

No response

Matplotlib Version

0.2.0.dev53887+unknown.g607d2c380.gc46efc9e5

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions