HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/holoviews/examples/reference/streams/plotly/BoundsX.ipynb
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### **Title**: BoundsX stream example\n",
    "\n",
    "**Description**: A linked streams example demonstrating how to use BoundsX streams.\n",
    "\n",
    "**Dependencies**: Plotly\n",
    "\n",
    "**Backends**: [Plotly](./BoundsX.ipynb), [Bokeh](../bokeh/BoundsX.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import holoviews as hv\n",
    "from holoviews import streams\n",
    "hv.extension('plotly')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "n=200\n",
    "np.random.seed(20)\n",
    "xs = np.linspace(0, 1, n)\n",
    "ys = np.cumsum(np.random.randn(n))\n",
    "df = pd.DataFrame({'x': xs, 'y': ys})\n",
    "curve = hv.Scatter(df)\n",
    "\n",
    "def make_from_boundsx(boundsx):\n",
    "    sub = df.set_index('x').loc[boundsx[0]:boundsx[1]]\n",
    "    return hv.Table(sub.describe().reset_index().values, 'stat', 'value')\n",
    "\n",
    "dmap = hv.DynamicMap(make_from_boundsx, streams=[streams.BoundsX(source=curve, boundsx=(0,0))])\n",
    "\n",
    "curve + dmap"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center><img src=\"https://assets.holoviews.org/gifs/examples/streams/plotly/boundsx_selection.gif\"></center>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}