Set number of lags in Python pandas autocorrelation_plot
autocorrelation_plot
returns a matplotlib.axis object. Hence, you can simply use the set_xlim()
method to limit the x-axis:
autocorrelation_plot(xx).set_xlim([0, 10])
Reference
Just as a backup solution, if one does not need to use pandas
methods. There is a statsmodels
function plot_acf
in which you can set the lags
argument.
from statsmodels.graphics.tsaplots import plot_acf
import pandas as pd
d = dict()
d['value'] = [11, 22, 34, 22, 43, 23, 45, 32, 56, 40, 44, 33, 22, 56, 44]
df = pd.DataFrame.from_dict(d)
plot_acf(df, lags = 5)