{ "cells": [ { "cell_type": "markdown", "id": "41296cc6-9d84-47c5-8a92-2d292f6f3c4a", "metadata": { "papermill": { "duration": 0.01523, "end_time": "2024-01-31T17:49:38.190595", "exception": false, "start_time": "2024-01-31T17:49:38.175365", "status": "completed" }, "tags": [] }, "source": [ "# Plots" ] }, { "cell_type": "code", "execution_count": 1, "id": "9286e0b8-3c78-4b0f-943c-d219e9840dfe", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.399978600Z", "start_time": "2023-11-22T14:30:12.220250Z" }, "papermill": { "duration": 0.015281, "end_time": "2024-01-31T17:49:38.214428", "exception": false, "start_time": "2024-01-31T17:49:38.199147", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Import to be able to import python package from src\n", "import sys\n", "sys.path.insert(0, '../src')" ] }, { "cell_type": "code", "execution_count": 2, "id": "2028eed7-b1c3-4c9e-b6a0-00433caa7d0f", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.438915100Z", "start_time": "2023-11-22T14:30:12.223262200Z" }, "papermill": { "duration": 2.494197, "end_time": "2024-01-31T17:49:40.714680", "exception": false, "start_time": "2024-01-31T17:49:38.220483", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "The `LightGBM` module could not be imported. To enable LightGBM support in Darts, follow the detailed instructions in the installation guide: https://github.com/unit8co/darts/blob/master/INSTALL.md\n", "The `Prophet` module could not be imported. To enable Prophet support in Darts, follow the detailed instructions in the installation guide: https://github.com/unit8co/darts/blob/master/INSTALL.md\n" ] } ], "source": [ "import pandas as pd\n", "import ontime as on\n", "from darts.datasets import EnergyDataset" ] }, { "cell_type": "markdown", "id": "e24da8ab-6a83-4c2f-9ff0-c633d4693a91", "metadata": { "papermill": { "duration": 0.004156, "end_time": "2024-01-31T17:49:40.723198", "exception": false, "start_time": "2024-01-31T17:49:40.719042", "status": "completed" }, "tags": [] }, "source": [ "## Load data" ] }, { "cell_type": "code", "execution_count": 3, "id": "db08372d-8ab2-4290-9196-76eb0c275629", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.886891300Z", "start_time": "2023-11-22T14:30:12.235870500Z" }, "papermill": { "duration": 0.070649, "end_time": "2024-01-31T17:49:40.797936", "exception": false, "start_time": "2024-01-31T17:49:40.727287", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "ts = EnergyDataset().load()" ] }, { "cell_type": "markdown", "id": "789865e9-e840-4267-994a-f10743e46279", "metadata": { "papermill": { "duration": 0.004193, "end_time": "2024-01-31T17:49:40.806517", "exception": false, "start_time": "2024-01-31T17:49:40.802324", "status": "completed" }, "tags": [] }, "source": [ "Complete TimeSeries" ] }, { "cell_type": "code", "execution_count": 4, "id": "009bcbe3-b73c-4355-b280-1bcb3d98e113", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.888403100Z", "start_time": "2023-11-22T14:30:12.382164600Z" }, "papermill": { "duration": 0.018375, "end_time": "2024-01-31T17:49:40.829148", "exception": false, "start_time": "2024-01-31T17:49:40.810773", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "df = ts.pd_dataframe()\n", "df = df.interpolate()\n", "cols = ['generation biomass', 'generation solar', 'generation nuclear']\n", "df = df[cols]" ] }, { "cell_type": "code", "execution_count": 5, "id": "7baaa1c5-c460-44bb-a375-f2eff4509cee", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.888403100Z", "start_time": "2023-11-22T14:30:12.406885100Z" }, "papermill": { "duration": 0.008708, "end_time": "2024-01-31T17:49:40.842048", "exception": false, "start_time": "2024-01-31T17:49:40.833340", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "ts = on.TimeSeries.from_dataframe(df)" ] }, { "cell_type": "markdown", "id": "07386885-6139-43ed-a695-c2fa3cf23904", "metadata": { "papermill": { "duration": 0.004101, "end_time": "2024-01-31T17:49:40.850253", "exception": false, "start_time": "2024-01-31T17:49:40.846152", "status": "completed" }, "tags": [] }, "source": [ "Prepare data" ] }, { "cell_type": "code", "execution_count": 6, "id": "07b54c1f-4215-43c0-8c81-bb337b9f50fb", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.888403100Z", "start_time": "2023-11-22T14:30:12.414642100Z" }, "papermill": { "duration": 0.010221, "end_time": "2024-01-31T17:49:40.864515", "exception": false, "start_time": "2024-01-31T17:49:40.854294", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "ts_uni = ts['generation solar'].slice(pd.Timestamp('2015'), pd.Timestamp('2016'))\n", "ts_multi = ts.slice(pd.Timestamp('2015'), pd.Timestamp('2016'))" ] }, { "cell_type": "markdown", "id": "a1a7ecfe-894b-42a8-8a94-5163f83b26a4", "metadata": {}, "source": [ "## Primitive Plots" ] }, { "cell_type": "markdown", "id": "a438a78b-3ed5-4501-a316-2414e881dbb3", "metadata": {}, "source": [ "### Line(s)" ] }, { "cell_type": "markdown", "id": "8c60d9ea-e027-4ba0-8fc6-87bfd8059084", "metadata": { "papermill": { "duration": 0.00435, "end_time": "2024-01-31T17:49:40.963591", "exception": false, "start_time": "2024-01-31T17:49:40.959241", "status": "completed" }, "tags": [] }, "source": [ "With univariate TimeSeries" ] }, { "cell_type": "code", "execution_count": 7, "id": "ad694d28-07ff-4563-81a6-84ffe6591b70", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_uni.head(400))\\\n", " .add(on.marks.line)\\\n", " .properties(width=600)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "4de943c7-b0fd-4943-8cb1-8ce496599864", "metadata": { "papermill": { "duration": 0.006692, "end_time": "2024-01-31T17:49:41.118951", "exception": false, "start_time": "2024-01-31T17:49:41.112259", "status": "completed" }, "tags": [] }, "source": [ "with multivariate TimeSeries" ] }, { "cell_type": "code", "execution_count": 8, "id": "2a4a0582-209b-461a-815b-7d4d4698c0f7", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.940457Z", "start_time": "2023-11-22T14:30:12.570624900Z" }, "papermill": { "duration": 0.105309, "end_time": "2024-01-31T17:49:41.230778", "exception": false, "start_time": "2024-01-31T17:49:41.125469", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_multi.head(400))\\\n", " .add(on.marks.line)\\\n", " .properties(width=600)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "2fd66619-22c4-43b5-b827-39b01d16e73b", "metadata": {}, "source": [ "### Dots" ] }, { "cell_type": "markdown", "id": "e1e97a4e-352d-446f-a70f-66c83e6754e1", "metadata": {}, "source": [ "With univariate TimeSeries" ] }, { "cell_type": "code", "execution_count": 9, "id": "f25a59e9-98d3-4519-bc03-feb9f6cd4d2a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_uni.head(400))\\\n", " .add(on.marks.dots)\\\n", " .properties(width=600)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "8b7e5730-9341-404d-93a9-f6811d2775d9", "metadata": {}, "source": [ "with multivariate TimeSeries" ] }, { "cell_type": "code", "execution_count": 10, "id": "e02804dd-0c24-40e4-9acc-8ed817f03a12", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_multi.head(400))\\\n", " .add(on.marks.dots)\\\n", " .properties(width=600)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "f9b6835a-2bbf-48d6-935d-fa6226cf45c1", "metadata": {}, "source": [ "### Areas" ] }, { "cell_type": "markdown", "id": "8c8f8fc6-ccfd-4c3f-b513-e14842e7849c", "metadata": {}, "source": [ "With a single time series" ] }, { "cell_type": "code", "execution_count": 11, "id": "7db16759-fbf2-46ef-a0da-4eea94f8ca60", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_uni.head(400))\\\n", " .add(on.marks.area)\\\n", " .properties(width=600)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "54c8348a-fafe-49c4-939f-77f1a7a2c9d6", "metadata": {}, "source": [ "With a multivariate time series it works with exactly two" ] }, { "cell_type": "code", "execution_count": 12, "id": "d6b18ef8-7954-4780-8e9a-dd6e8afd6d15", "metadata": {}, "outputs": [], "source": [ "from darts import concatenate" ] }, { "cell_type": "code", "execution_count": 13, "id": "70178386-e035-4c7a-91c2-ee206131635d", "metadata": {}, "outputs": [], "source": [ "# First we create the series with two components\n", "ts_ci = concatenate([\n", " ts_multi.univariate_component(0), \n", " ts_multi.univariate_component(1)\n", "], axis=1)\n", "ts_ci = on.TimeSeries.from_darts(ts_ci)" ] }, { "cell_type": "code", "execution_count": 14, "id": "98ca8c64-bcde-4e93-a0ec-df1410242f36", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Then we plot it\n", "on.Plot(ts_ci.head(200))\\\n", " .add(on.marks.area, title='Diff. between solar and biomass generation')\\\n", " .properties(width=600, height=200)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "f436ba6f-aa4f-47e8-9673-754c9c02e1b4", "metadata": { "papermill": { "duration": 0.013993, "end_time": "2024-01-31T17:49:41.259259", "exception": false, "start_time": "2024-01-31T17:49:41.245266", "status": "completed" }, "tags": [] }, "source": [ "### Heatmaps" ] }, { "attachments": {}, "cell_type": "markdown", "id": "94b74653-0b50-442f-a666-9bd0984f9781", "metadata": { "papermill": { "duration": 0.014072, "end_time": "2024-01-31T17:49:41.320059", "exception": false, "start_time": "2024-01-31T17:49:41.305987", "status": "completed" }, "tags": [] }, "source": [ "with univariate TimeSeries" ] }, { "cell_type": "code", "execution_count": 15, "id": "8a70db18-2736-4b52-8a49-a09908048535", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_uni.head(1000))\\\n", " .add(on.marks.heatmap)\\\n", " .properties(width=600, height=50)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "bb43360b-c5ff-4e95-9af8-7ced3fb66d7d", "metadata": { "papermill": { "duration": 0.01433, "end_time": "2024-01-31T17:49:41.415862", "exception": false, "start_time": "2024-01-31T17:49:41.401532", "status": "completed" }, "tags": [] }, "source": [ "with multivariate Heatmap" ] }, { "cell_type": "code", "execution_count": 23, "id": "95e245b4-d594-45f7-ae7a-04db01fc860d", "metadata": { "ExecuteTime": { "end_time": "2023-11-22T14:30:12.943458900Z", "start_time": "2023-11-22T14:30:12.778200200Z" }, "papermill": { "duration": 0.052047, "end_time": "2024-01-31T17:49:41.386466", "exception": false, "start_time": "2024-01-31T17:49:41.334419", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot(ts_multi.head(1000))\\\n", " .add(on.marks.heatmap)\\\n", " .properties(width=600, height=150)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "3b07d001-bef6-4b9b-86b6-105ad318adab", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "id": "8a52c3c7-3adf-454e-9b6d-b0959adcd8f6", "metadata": {}, "source": [ "## Combined Plots" ] }, { "cell_type": "markdown", "id": "c29b1243-bc85-4a8d-899a-710cbfc2d77b", "metadata": {}, "source": [ "Most of the plots in onTime can be combined as they are based on Altair layered charts. For instance, you can do the following to have a dots on a line." ] }, { "cell_type": "code", "execution_count": 24, "id": "e18041c8-4c74-4f63-be92-56ad1d971bf7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "on.Plot()\\\n", " .add(on.marks.dots, ts_multi.univariate_component(1).head(400))\\\n", " .add(on.marks.line, ts_multi.univariate_component(0).head(400))\\\n", " .properties(width=600, height=200)\\\n", " .show()" ] }, { "cell_type": "markdown", "id": "8c1f4d05-d5b2-4d86-8cf0-6165175354eb", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "id": "e87e999c-4ffa-4f3a-92a8-db894982a2ae", "metadata": {}, "source": [ "## Thematic Plots" ] }, { "cell_type": "markdown", "id": "b65f9e0b-381a-4085-b919-3074b9b18b0a", "metadata": {}, "source": [ "### Forecasts" ] }, { "cell_type": "code", "execution_count": 25, "id": "79328857-d576-43d4-a54a-29196312448b", "metadata": {}, "outputs": [], "source": [ "ts_train, ts_test = ts_uni.split_before(0.9)" ] }, { "cell_type": "code", "execution_count": 26, "id": "53bdff9e-f198-4a24-9968-95c3efaf5ebb", "metadata": {}, "outputs": [], "source": [ "from ontime.context import common" ] }, { "cell_type": "code", "execution_count": 27, "id": "c592bccc-95bf-4b2d-9952-f1b4075288da", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model = common.GenericPredictor()\n", "model.fit(ts_train)" ] }, { "cell_type": "code", "execution_count": 28, "id": "7a92c059-8854-4d26-a51e-5c44cb7fa1e1", "metadata": {}, "outputs": [], "source": [ "ts_pred = model.predict(24 * 3)" ] }, { "cell_type": "code", "execution_count": 29, "id": "609375fd-e994-4336-b1e8-07ea11b38d49", "metadata": {}, "outputs": [], "source": [ "ts_train = ts_train.rename({'generation solar':'Training set'})\n", "ts_test = ts_test.rename({'generation solar':'Test set'})\n", "ts_pred = ts_pred.rename({'generation solar':'Forecast'})" ] }, { "cell_type": "markdown", "id": "2f6c72b8-2124-452f-9577-f4d4ece10803", "metadata": {}, "source": [ "Plot a prediction" ] }, { "cell_type": "code", "execution_count": 30, "id": "99165fdc-d0a5-49d5-a882-adb8b8534e54", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(\n", "on.Plot()\n", " .add(on.marks.line, ts_test.head(24 * 3), type='dashed')\n", " .add(on.marks.line, ts_train.tail(24 * 4))\n", " .add(on.marks.line, ts_pred)\n", " .properties(width=600, height=200)\n", " .show()\n", ")" ] }, { "cell_type": "markdown", "id": "8b2d1199-7a74-4586-a834-67fc367229e4", "metadata": {}, "source": [ "### Anomalies" ] }, { "cell_type": "markdown", "id": "9424f948-96fe-4a51-987a-9c323c1af142", "metadata": {}, "source": [ "Create the mock data" ] }, { "cell_type": "code", "execution_count": 56, "id": "0bea5b4f-e11b-4836-a039-d61117a4684d", "metadata": {}, "outputs": [], "source": [ "td_point = on.detectors.quantile(high_quantile=0.99)\n", "td_collective = on.detectors.threshold(low_threshold=-30)\n", "td_contextual = on.detectors.quantile(high_quantile=0.98)" ] }, { "cell_type": "markdown", "id": "06a7f815-c162-4243-97d9-c8e7e84a6b02", "metadata": {}, "source": [ "Add anomalies" ] }, { "cell_type": "code", "execution_count": 57, "id": "e5c7dba4-1ff8-47c9-907b-4bde47ca09dc", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import random\n", "\n", "def add_point_anomalies(ts, n, value):\n", " df = ts.pd_dataframe()\n", " random_indices = np.random.choice(df.index, size=n, replace=False)\n", " df.loc[random_indices] = value\n", " return on.TimeSeries.from_dataframe(df)\n", "\n", "def add_collective_anomalies(ts, n, min_duration=10, max_duration=20):\n", " df = ts.pd_dataframe()\n", " for i in range(n+1):\n", " block_duration = random.randint(min_duration, max_duration)\n", " start_index = np.random.choice(df.index[:-block_duration])\n", " end_index = start_index + pd.Timedelta(days=block_duration - 1)\n", " df.loc[start_index:end_index] = -40\n", " return on.TimeSeries.from_dataframe(df)" ] }, { "cell_type": "markdown", "id": "610cfd2a-c6eb-45bb-a51d-f384dc5a29e9", "metadata": {}, "source": [ "Select univariate component" ] }, { "cell_type": "code", "execution_count": 58, "id": "9e89c5ca-3456-446c-8b5e-507574f43df5", "metadata": {}, "outputs": [], "source": [ "ts = ts.univariate_component(0)" ] }, { "cell_type": "code", "execution_count": 59, "id": "03364cbd-61aa-4660-9789-ab7f4662ab79", "metadata": {}, "outputs": [], "source": [ "ts = add_point_anomalies(ts, 10, 30)\n", "ts = add_collective_anomalies(ts, 4)" ] }, { "cell_type": "markdown", "id": "370bdde9-662f-43e7-ab93-cd79b8e2f624", "metadata": {}, "source": [ "Create binary time series" ] }, { "cell_type": "code", "execution_count": 60, "id": "4f810223-cfd2-429b-8d7d-6182c26d7246", "metadata": {}, "outputs": [], "source": [ "td_point.fit(ts)\n", "td_contextual.fit(ts)\n", "\n", "ts_ano_point = td_point.detect(ts)\n", "ts_ano_collective = td_collective.detect(ts)\n", "ts_ano_contextual = td_contextual.detect(ts)" ] }, { "cell_type": "code", "execution_count": 61, "id": "d0d58fb4-2104-444c-9385-6597beb81a6d", "metadata": {}, "outputs": [], "source": [ "ts_ano_point = ts_ano_point.rename({'0': 'Ponctual anomalies'})\n", "ts_ano_collective = ts_ano_collective.rename({'0': 'Collective anomalies'})\n", "ts_ano_contextual = ts_ano_contextual.rename({'0': 'Contextual anomalies'})" ] }, { "cell_type": "markdown", "id": "873160d1-4b22-41c5-b374-67b9f9124754", "metadata": {}, "source": [ "Plot the time series with marked anomalies" ] }, { "cell_type": "code", "execution_count": 64, "id": "2e944b87-b85d-4c5c-b963-857f79e6b2a4", "metadata": {}, "outputs": [], "source": [ "# Define windows for plotting\n", "start = 24 * 7 * 4 * 9\n", "duration = 24 * 7 * 10\n", "end = start + duration" ] }, { "cell_type": "code", "execution_count": 67, "id": "d4e93bfd-5e3e-40d4-9c45-577eff06579a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Actually plot\n", "(\n", "on.Plot(ts[start:end])\n", " .add(on.marks.mark, data=ts_ano_contextual[start:end], type='highlight')\n", " .add(on.marks.mark, data=ts_ano_collective[start:end], type='background')\n", " .add(on.marks.line)\n", " .add(on.marks.mark, data=ts_ano_point[start:end], type='dot')\n", " .properties(width=800, height=200)\n", " .show()\n", ")" ] }, { "cell_type": "markdown", "id": "ba882e58-d1ba-4bd9-9b8b-11c5257986b2", "metadata": {}, "source": [ "### Confidence Intervals" ] }, { "cell_type": "code", "execution_count": 91, "id": "af517b10-9441-4d17-9664-6eb35e4afef3", "metadata": {}, "outputs": [], "source": [ "# Generate two time series\n", "ts1 = on.generators.random_walk().generate(start=pd.Timestamp('2022-01-01'), end=pd.Timestamp('2022-12-31'))\n", "ts2 = on.generators.random_walk().generate(start=pd.Timestamp('2022-01-01'), end=pd.Timestamp('2022-12-31'))" ] }, { "cell_type": "code", "execution_count": 92, "id": "0a73d11f-4b21-45a8-8101-79fa3105d293", "metadata": {}, "outputs": [], "source": [ "# First we create the series with two components\n", "ts1_abs = ts1.map(np.abs)\n", "ts2_abs = ts2.map(np.abs)\n", "ts_ci = concatenate([ts1_abs, ts2_abs], axis=1)\n", "ts_ci = on.TimeSeries.from_darts(ts_ci)\n", "ts_ci = ts_ci.rename({'random_walk': 'CI Upper bound', 'random_walk_1': 'CI Lower bound'})\n", "\n", "# Then the hypothetical measurement\n", "ts_mid = (ts1_abs + ts2_abs) / 2\n", "ts_mid = ts_mid.rename({'random_walk': 'Measurement'})" ] }, { "cell_type": "code", "execution_count": 93, "id": "3a12d720-4522-4aac-ae54-5975b52848aa", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.LayerChart(...)" ] }, "execution_count": 93, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Then we plot it\n", "(\n", "on.Plot() # main line\n", " .add(on.marks.area, ts_ci.head(200), title='Confidence interval')\n", " .add(on.marks.line, ts_mid.head(200))\n", " .properties(width=600, height=200)\n", " .show()\n", ")" ] }, { "cell_type": "markdown", "id": "cd9ce3e4-e4a8-40ca-b128-91b80cf1b933", "metadata": {}, "source": [ "---" ] }, { "cell_type": "code", "execution_count": null, "id": "2da36027-d7dc-4274-9046-a8054c615c0e", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" }, "papermill": { "default_parameters": {}, "duration": 8.089169, "end_time": "2024-01-31T17:49:45.591711", "environment_variables": {}, "exception": null, "input_path": "docs/user_guide/0_core/0.5-plots.ipynb", "output_path": "docs/user_guide/0_core/0.5-plots.ipynb", "parameters": {}, "start_time": "2024-01-31T17:49:37.502542", "version": "2.5.0" } }, "nbformat": 4, "nbformat_minor": 5 }