Skip to content

Contour "level" keyword arg #13456

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
jasalper opened this issue Feb 17, 2019 · 3 comments
Closed

Contour "level" keyword arg #13456

jasalper opened this issue Feb 17, 2019 · 3 comments
Milestone

Comments

@jasalper
Copy link

jasalper commented Feb 17, 2019

Bug report

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contourf.html#matplotlib.pyplot.contourf
As per the documentation for contour plots, when you pass "levels" as a keyword argument, it sets an instance attribute which breaks the _contour_level_args function.

Code for reproduction

import matplotlib.pyplot as plt

x = np.arange(-1, 1, 0.1)
y = np.arange(-1, 1, 0.1)

X, Y = np.meshgrid(x, y)

Z = (1-X)**2 + Y**2 # or some other function
fig, ax = plt.subplots()
CS = ax.contourf(X, Y, Z, levels=10)

The issue is in the _contour_level_args function in contour.py, where self.levels is not none because you're passing levels as a keyword argument, which seems to indicate that levels is parsed strangely?

Matplotlib version

  • Operating system: Mojave
  • Matplotlib version: 3.0.2
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:

I installed with conda

@ImportanceOfBeingErnest
Copy link
Member

The code you show runs fine with matplotlib 3.0.2. It would throw an error in matplotlib 2.2.3 though.
See #12762 from this comment downwards, as well as #11917.

As mentionned in #12762, maybe we should care about backporting #11917.

@jklymak
Copy link
Member

jklymak commented Mar 4, 2019

Backport attempt at #13583

@jklymak jklymak mentioned this issue Mar 4, 2019
6 tasks
@jklymak jklymak added this to the v2.2.5 milestone Mar 4, 2019
@jklymak
Copy link
Member

jklymak commented Mar 4, 2019

Closed by #13583; this will be in the next bug fix of 2.2 branch

@jklymak jklymak closed this as completed Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants