Skip to content

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

Closed

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

  1. jklymak commented on Oct 11, 2023

    @jklymak
    Member

    Did this break, or did it never work?

  2. rho-novatron commented on Oct 11, 2023

    @rho-novatron
    Author

    It looks correct in 3.7.3. I updated the "expected outcome" screenshot from that.

  3. rho-novatron commented on Oct 11, 2023

    @rho-novatron
    Author

    It is also still broken in main now (6501209 )

  4. ksunden commented on Oct 11, 2023

    @ksunden
    Member

    I was able to fix this with a one line change, there was a line that struck me as possibly wrong when looking into #26971, but it was not related to that one, and was instead related to this bug. I'll add it to #27045

  5. added a commit that references this issue on Oct 11, 2023
    f0a3a09
  6. rho-novatron commented on Oct 11, 2023

    @rho-novatron
    Author

    Yay - the one-liner works for me. Thanks!

  7. added this to the v3.8.1 milestone on Oct 26, 2023
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