Skip to content

Commit e5c18b4

Browse files
gliptakjreback
authored andcommitted
BUG: Correct KeyError from matplotlib when processing Series yerr
closes #11858 Author: Gábor Lipták <[email protected]> Closes #13114 from gliptak/yerr1 and squashes the following commits: 926329a [Gábor Lipták] Correct KeyError from matplotlib when processing Series xerr/yerr
1 parent c9ffd78 commit e5c18b4

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

codecov.yml

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ coverage:
77
default:
88
target: '50'
99
branches: null
10-
changes:
11-
default:
12-
branches:
13-
- master

doc/source/whatsnew/v0.18.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Other enhancements
3333

3434

3535

36-
3736
.. _whatsnew_0182.api:
3837

3938
API changes
@@ -108,6 +107,7 @@ Performance Improvements
108107
Bug Fixes
109108
~~~~~~~~~
110109
- Bug in ``SparseDataFrame`` in which ``axis=None`` did not default to ``axis=0`` (:issue:`13048`)
110+
- Bug when passing a not-default-indexed ``Series`` as ``xerr`` or ``yerr`` in ``.plot()`` (:issue:`11858`)
111111

112112

113113

pandas/tools/plotting.py

+4
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,10 @@ def _plot(cls, ax, x, y, style=None, is_errorbar=False, **kwds):
13311331
x = x._mpl_repr()
13321332

13331333
if is_errorbar:
1334+
if 'xerr' in kwds:
1335+
kwds['xerr'] = np.array(kwds.get('xerr'))
1336+
if 'yerr' in kwds:
1337+
kwds['yerr'] = np.array(kwds.get('yerr'))
13341338
return ax.errorbar(x, y, **kwds)
13351339
else:
13361340
# prevent style kwarg from going to errorbar, where it is

pandas/tseries/tests/test_plotting.py

+7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ def test_frame_inferred(self):
7676
df = DataFrame(np.random.randn(len(idx), 3), index=idx)
7777
_check_plot_works(df.plot)
7878

79+
def test_is_error_nozeroindex(self):
80+
# GH11858
81+
i = np.array([1, 2, 3])
82+
a = DataFrame(i, index=i)
83+
_check_plot_works(a.plot, xerr=a)
84+
_check_plot_works(a.plot, yerr=a)
85+
7986
def test_nonnumeric_exclude(self):
8087
import matplotlib.pyplot as plt
8188

0 commit comments

Comments
 (0)