{ "cells": [ { "cell_type": "markdown", "id": "188d2814-6a99-49a1-8968-abd9b3e503ea", "metadata": {}, "source": [ "# Scale Time" ] }, { "cell_type": "code", "execution_count": 1, "id": "a68b1c0c", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:04:19.288151Z", "iopub.status.busy": "2026-01-27T17:04:19.288056Z", "iopub.status.idle": "2026-01-27T17:04:19.290777Z", "shell.execute_reply": "2026-01-27T17:04:19.290492Z" } }, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "b3826f1a-4006-4706-9d90-dc8e022565ed", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:04:19.291557Z", "iopub.status.busy": "2026-01-27T17:04:19.291483Z", "iopub.status.idle": "2026-01-27T17:04:19.293119Z", "shell.execute_reply": "2026-01-27T17:04:19.292833Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "4377ea51", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:04:19.294064Z", "iopub.status.busy": "2026-01-27T17:04:19.293977Z", "iopub.status.idle": "2026-01-27T17:04:19.296375Z", "shell.execute_reply": "2026-01-27T17:04:19.296007Z" } }, "outputs": [], "source": [ "def time_plot(title, time, y=False):\n", " np.random.seed(0)\n", " value = np.random.normal(loc=-5, scale=6, size=len(time))\n", " d = {'time': time, 'value': value}\n", " if y:\n", " return ggplot(d) + geom_line(aes('value', 'time')) + scale_y_time() + ggtitle(title)\n", " else:\n", " return ggplot(d) + geom_line(aes('time', 'value')) + scale_x_time() + ggtitle(title)\n", "\n", "def serie(start, end, duration, step = None):\n", " if step is None:\n", " step = 1 * duration\n", " \n", " return [v for v in range(start * duration, end * duration, step)]\n", "\n", "MS = 1\n", "SECOND = 1000 * MS\n", "MINUTE = 60 * SECOND\n", "HOUR = 60 * MINUTE" ] }, { "cell_type": "code", "execution_count": 4, "id": "c3497852", "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:04:19.297104Z", "iopub.status.busy": "2026-01-27T17:04:19.297035Z", "iopub.status.idle": "2026-01-27T17:04:19.342074Z", "shell.execute_reply": "2026-01-27T17:04:19.341726Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "