-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Correct KeyError from matplotlib when processing Series yerr #13114
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
Conversation
# GH11858 | ||
i = np.array([1, 2, 3]) | ||
a = DataFrame(i, index=i) | ||
a.plot(yerr=a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use check_plot_works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
pls add a whatsnew note |
@jreback Which section would this go in whatsnew? |
bug fix |
left note on orginal issue, but can you please check if this is still a problem on mpl 1.5.1, 2.x or master? If so, please make an issue upstream. |
whatsnew added |
Also see matplotlib/matplotlib#6392 |
@tacaswell Based on the assessment by @diazona in #13114 (comment) , sending |
That fixes the pandas problem, but not the case where ax.errorbar('x', 'y', yerr='ye', data=df) This should probably go into pandas for use with non-patched versions of mpl, but in the long run mpl should be able to cope with |
@@ -1331,6 +1331,10 @@ def _plot(cls, ax, x, y, style=None, is_errorbar=False, **kwds): | |||
x = x._mpl_repr() | |||
|
|||
if is_errorbar: | |||
if 'xerr' in kwds: | |||
kwds['xerr'] = com._values_from_object(kwds.get('xerr')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually just do: np.array(kwds.get('xerr'))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Yep, I've confirmed that a test program like the following still reproduces the
|
Would this above be worked in a followup issue? Thanks |
I think it's worth investigating how to do a more "proper" fix, but I don't have time to get on that right now. Perhaps it is better to just incorporate this commit into the master branch and take care of the other cases later with a separate issue. I guess it's up to the Pandas developers. |
The pr into mpl fixes both issues. |
Build fail seems to be unrelated:
|
yeah go ahead and rebase, fixed a weird boto import issue |
I thought we were talking about allowing Pandas to work with older versions of matplotlib that don't have @tacaswell's patch. But if you'd rather say people should simply to upgrade matplotlib to avoid this bug, and leave it at that, that works too. Just checking that I'm on the same page as everyone else. |
thanks @gliptak yeh important that pandas fixes this (and of course even moreso for mpl) |
git diff upstream/master | flake8 --diff