Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tillahoffmann opened this issue Dec 12, 2017 · 6 comments · Fixed by #9989
Closed

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

tillahoffmann opened this issue Dec 12, 2017 · 6 comments · Fixed by #9989

Comments

@tillahoffmann
Copy link
Contributor

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.

@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

Thanks for the nice test. Interestingly its backend dependent: MacOS is OK, though different than the outplacement; Qt5Agg is worse than what you show above. I'd try Qt5Cairo, but its not merged yet :-(

@jklymak jklymak added this to the v2.2 milestone Dec 12, 2017
@tillahoffmann
Copy link
Contributor Author

Interesting. I'm ultimately interested in rendering to PDF. Do you think using the MacOS backend first and then using fig.savefig('/path/to.pdf') could do the trick?

@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

Oddly that does seem to do the trick. But.... This is still a bug.

@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

... a mercifully one-line bug... See #9989

@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

figure_1-1

@tillahoffmann
Copy link
Contributor Author

🎉 that was speedy! Thank you!

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

Successfully merging a pull request may close this issue.

3 participants