Skip to content
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

update errorbar in Matplotlib 2.0.0 #8586

Closed
mromanie opened this issue May 7, 2017 · 5 comments
Closed

update errorbar in Matplotlib 2.0.0 #8586

mromanie opened this issue May 7, 2017 · 5 comments

Comments

@mromanie
Copy link
Contributor

mromanie commented May 7, 2017

I want to update matplotlib errorbar plotting as some input data varies. The code at:

#4556

doesn't seem to work with matplotlib 2.0.0 (works fine with version 1.5.2rc2). Hints? Thanks!!

Code for reproduction

For example:

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
x = np.linspace(0, 2*np.pi, 15)
y = np.sin(x)
y_err = np.cos(x) * 0.1
err = ax.errorbar(x, y, y_err)
ln, (err_top, err_bot), (bars, ) = err

Actual outcome

returns the following erro:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 0 values to unpack

It used to work on 1.5.2rc2 and python 2.7.12.

Matplotlib version

  • Operating System: Mac OS X 10.11.6
  • Matplotlib Version: 2.0.0
  • Python Version: 2.7.13
  • Jupyter Version (if applicable):
  • Other Libraries:

Both python and matplotlib installed from MacPorts.

@tacaswell
Copy link
Member

This is due to a change in the default behavior of errorbarr (https://matplotlib.org/users/dflt_style_changes.html#errorbar) where we no longer draw the caps by default. This results in err[1] being an empty tuple rather than a length 2 tuple which is an API change we failed to document.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue May 7, 2017
@tacaswell tacaswell added this to the 2.0.2 (critical bug fixes from 2.0.1) milestone May 7, 2017
@mromanie
Copy link
Contributor Author

mromanie commented May 8, 2017 via email

@tacaswell
Copy link
Member

The third artist (the vertical lines) have the errors.

Closed by #8588

@mromanie
Copy link
Contributor Author

mromanie commented May 9, 2017 via email

@tacaswell
Copy link
Member

ln, _, (bars,) = err

should work

or

ln, *_, (bars, ) = err

in python3

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

2 participants