{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### **Title**: Curve selection streams example\n", "\n", "**Description**: A linked streams example demonstrating how to use the Selection1D stream to access Curves selected using a tap tool on one plot and mirror them on another plot.\n", "\n", "**Dependencies**: Bokeh\n", "\n", "**Backends**: [Bokeh](./Selection1D.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import holoviews as hv\n", "from holoviews import opts\n", "from holoviews import streams\n", "hv.extension('bokeh')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ndoverlay = hv.NdOverlay({i: hv.Curve(np.arange(10)*i) for i in range(5)})\n", "\n", "selection = streams.Selection1D(source=ndoverlay)\n", "dmap = hv.DynamicMap(lambda index: ndoverlay[index] if index else ndoverlay.clone(),\n", " kdims=[], streams=[selection])\n", "layout = ndoverlay + dmap\n", "layout.opts(\n", " opts.Curve(tools=['tap'], line_width=10),\n", " opts.NdOverlay(legend_limit=0))" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }