Skip to content

Commit 8a8a02e

Browse files
author
TomAugspurger
committed
BUG/API: autocorrelation_plot should accept kwargs
1 parent 2d571e6 commit 8a8a02e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/release.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ API Changes
6161
- Raise/Warn ``SettingWithCopyError`` (according to the option ``chained_assignment`` in more cases,
6262
when detecting chained assignment, related (:issue:`5938`)
6363
- DataFrame.head(0) returns self instead of empty frame (:issue:`5846`)
64+
- ``autocorrelation_plot`` now accepts ``**kwargs``. (:issue:`5623`)
6465

6566
Experimental Features
6667
~~~~~~~~~~~~~~~~~~~~~

pandas/tests/test_graphics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ def test_autocorrelation_plot(self):
299299
_check_plot_works(autocorrelation_plot, self.ts)
300300
_check_plot_works(autocorrelation_plot, self.ts.values)
301301

302+
ax = autocorrelation_plot(self.ts, label='Test')
303+
t = ax.get_legend().get_texts()[0].get_text()
304+
self.assertEqual(t, 'Test')
305+
302306
@slow
303307
def test_lag_plot(self):
304308
from pandas.tools.plotting import lag_plot

pandas/tools/plotting.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,15 @@ def lag_plot(series, lag=1, ax=None, **kwds):
672672
return ax
673673

674674

675-
def autocorrelation_plot(series, ax=None):
675+
def autocorrelation_plot(series, ax=None, **kwds):
676676
"""Autocorrelation plot for time series.
677677
678678
Parameters:
679679
-----------
680680
series: Time series
681681
ax: Matplotlib axis object, optional
682+
kwds : keywords
683+
Options to pass to matplotlib plotting method
682684
683685
Returns:
684686
-----------
@@ -705,7 +707,9 @@ def r(h):
705707
ax.axhline(y=-z99 / np.sqrt(n), linestyle='--', color='grey')
706708
ax.set_xlabel("Lag")
707709
ax.set_ylabel("Autocorrelation")
708-
ax.plot(x, y)
710+
ax.plot(x, y, **kwds)
711+
if 'label' in kwds:
712+
ax.legend()
709713
ax.grid()
710714
return ax
711715

0 commit comments

Comments
 (0)