2015-08-21 86 views
1

我想找到一種方法在seaborn或statsmodels的能力產生散點圖矩陣lag.plot1 r。我可以實現一個簡單的版本如下:有沒有像Python中的`lag.plot1`這樣的Python中的方法?

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) 

enter image description here

回答

相關問題