Skip to content

Contours are not removed correctly when using clabel with manual #9988

Closed
@tillahoffmann

Description

@tillahoffmann

Bug report

Bug summary

Contours created using pyplot.contour are not correctly removed when labelling the contours usingplt.clabel invoked with inline=True and manual positions.

Code for reproduction

import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(-1, 1)
xx, yy = np.meshgrid(x, x)

fig, axes = plt.subplots(1, 2, True, True)

manual = None
for ax in axes:
    cs = ax.contour(x, x, xx ** 2 + yy ** 2)
    clabels = plt.clabel(cs, manual=manual)
    manual = [label.get_position() for label in clabels]

Expected outcome on the left, actual outcome on the right

image

Matplotlib version

  • Operating system: Linux 273ceb986a84 4.9.49-moby Fix autofmt_xdate() when using in conjunction with twinx() #1 SMP Wed Sep 27 23:17:17 UTC 2017 x86_64 GNU/Linux
  • Matplotlib version: 2.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.3
  • Jupyter version (if applicable): 4.4.0
  • Other libraries: numpy (1.13.3)

All libraries were installed using pip in a docker image derived from python:3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions