简体   繁体   中英

Is there any method in python like `lag.plot1` in r?

I want to find a method in seaborn or statsmodels with the ability produce scatterplot matrices as lag.plot1 in r. I could implement a simple version as following:

In [74]: def lag_plot1(x, nrow, ncol):
    ...:     import matplotlib.pyplot as plt
    ...:     fig, axs = plt.subplots(nrow, ncol, figsize=(3*ncol, 3*nrow))
    ...:     for row in range(nrow):
    ...:         for col in range(ncol):
    ...:             offset = row*ncol + col + 1
    ...:             axs[row][col].scatter(x[offset:], x[:-offset], marker='o')
    ...:             axs[row][col].set_ylabel('x(t)')
    ...:             axs[row][col].set_title('x(t-%d)' % offset)
    ...:     return fig
    ...: 

In [75]: lag_plot1(recur, 4, 3)

在此处输入图片说明

There is a lag_plot in pandas http://pandas.pydata.org/pandas-docs/stable/visualization.html#lag-plot but it doesn't plot the grid of plots for different lags, AFAICS.

statsmodels doesn't have a lag_plot, but there are still open issues to add more plots to support model diagnostics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM