Skip to content

Commit 926329a

Browse files
committed
Correct KeyError from matplotlib when processing Series xerr/yerr
1 parent 2a99394 commit 926329a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/source/whatsnew/v0.18.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Other enhancements
3030
^^^^^^^^^^^^^^^^^^
3131

3232
- The ``.tz_localize()`` method of ``DatetimeIndex`` and ``Timestamp`` has gained the ``errors`` keyword, so you can potentially coerce nonexistent timestamps to ``NaT``. The default behaviour remains to raising a ``NonExistentTimeError`` (:issue:`13057`)
33-
33+
- Correct ``KeyError`` from matplotlib when processing ``Series`` ``xerr``/``yerr`` (:issue:`13114`)
3434

3535

3636

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)