{ "cells": [ { "cell_type": "markdown", "id": "7eb37c52-8262-4359-a6c1-3214e675fa5d", "metadata": {}, "source": [ "# Lagplot" ] }, { "cell_type": "code", "execution_count": null, "id": "cb5dd3db-78c4-4a01-ba07-37f718f7425a", "metadata": {}, "outputs": [], "source": [ "import hvplot.pandas # noqa\n", "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "c7af165e-4231-49ea-81d7-d07ad81a05da", "metadata": {}, "source": [ "Lag plots are most commonly used to look for patterns in time series data." ] }, { "cell_type": "markdown", "id": "815a51ab-5f61-4bea-bb56-e11a0f117718", "metadata": {}, "source": [ "Given the following time series:" ] }, { "cell_type": "code", "execution_count": null, "id": "283adbd9-3c42-4cb7-8c57-1d0e9fe1d25f", "metadata": {}, "outputs": [], "source": [ "np.random.seed(5)\n", "x = np.cumsum(np.random.normal(loc=1, scale=5, size=50))\n", "s = pd.Series(x, name='Time series')\n", "\n", "s.hvplot()" ] }, { "cell_type": "markdown", "id": "8a877a7d-11cb-4bcb-81e4-3936f061ba65", "metadata": {}, "source": [ "A lag plot with `lag=1` returns:" ] }, { "cell_type": "code", "execution_count": null, "id": "52be318e-fccd-461d-9813-c231b6f2997c", "metadata": {}, "outputs": [], "source": [ "hvplot.plotting.lag_plot(s, lag=1)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 5 }