MCPcopy Create free account
hub / github.com/holoviz/hvplot / lag_plot

Function lag_plot

hvplot/plotting/lag_plot.py:9–41  ·  view source on GitHub ↗

Lag plot for time series. A lag plot is a scatter plot of a time series against a lag of itself. It helps in visualizing the temporal dependence between observations by plotting the values at time `t` on the x-axis and the values at time `t + lag` on the y-axis. Parameters ----

(data, lag=1, **kwds)

Source from the content-addressed store, hash-verified

7
8@with_hv_extension
9def lag_plot(data, lag=1, **kwds):
10 """Lag plot for time series.
11
12 A lag plot is a scatter plot of a time series against a lag of itself. It helps
13 in visualizing the temporal dependence between observations by plotting the values
14 at time `t` on the x-axis and the values at time `t + lag` on the y-axis.
15
16 Parameters
17 ----------
18 data : Series or DataFrame
19 The time series to visualize.
20 lag : int, optional
21 Lag length of the scatter plot. Default is 1.
22 **kwds : optional
23 hvplot.scatter options
24
25 Returns
26 -------
27 obj : HoloViews object
28 The HoloViews representation of the plot.
29 """
30 if lag != int(lag) or int(lag) <= 0:
31 raise ValueError('lag must be a positive integer')
32 lag = int(lag)
33
34 values = data.values
35 y1 = 'y(t)'
36 y2 = f'y(t + {lag})'
37 lags = pd.DataFrame({y1: values[:-lag].T.ravel(), y2: values[lag:].T.ravel()})
38 if isinstance(data, pd.DataFrame):
39 lags['variable'] = np.repeat(data.columns, lags.shape[0] / data.shape[1])
40 kwds['c'] = 'variable'
41 return hvPlotTabular(lags)(y1, y2, kind='scatter', **kwds)

Callers

nothing calls this directly

Calls 1

hvPlotTabularClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…