[Bug]: ContourLabeler.clabel with manual != False breaks unconnected contours · Issue #27062 · matplotlib/matplotlib · GitHub
Skip to content

[Bug]: ContourLabeler.clabel with manual != False breaks unconnected contours #27062

Description

@rho-novatron

Bug summary

When adding contour label positions manually (either via clicking or specifying an iterable of positions), contours with disconnected parts are not handled correctly, but sometimes rejoined seemingly arbitrarily.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
x, y = np.mgrid[-1:1:21j, -1:1:21j]

cs = ax.contour(x, y, 1/np.sqrt(0.01+(x+0.3)**2+y**2) + 1/np.sqrt(0.01+(x-0.3)**2+y**2), levels=[7])
cs.clabel(manual=[(0.2, 0.1)])

Actual outcome

image

Expected outcome

As it looked in matplotlib 3.7.3:
image

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.0

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

conda

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions