{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### **Title**: BoundsY stream example\n", "\n", "**Description**: A linked streams example demonstrating how to use BoundsY streams.\n", "\n", "**Dependencies** Plotly\n", "\n", "**Backends** [Plotly](./BoundsY.ipynb), [Bokeh](../bokeh/BoundsY.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import holoviews as hv\n", "from holoviews import opts, streams\n", "\n", "hv.extension('plotly')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xs = np.linspace(0, 1, 200)\n", "ys = xs*(1-xs)\n", "curve = hv.Curve((xs,ys))\n", "scatter = hv.Scatter((xs,ys)).opts(size=1)\n", "\n", "bounds_stream = streams.BoundsY(source=curve,boundsy=(0,0))\n", "\n", "def make_area(boundsy):\n", " return hv.Area((xs, np.minimum(ys, boundsy[0]), np.minimum(ys, boundsy[1])), vdims=['min','max'])\n", "\n", "\n", "def make_items(boundsy):\n", " times = [\"{0:.2f}\".format(x) for x in sorted(np.roots([-1,1,-boundsy[0]])) + sorted(np.roots([-1,1,-boundsy[1]]))]\n", " return hv.ItemTable(sorted(zip(['1_entry', '2_exit', '1_exit', '2_entry'], times)))\n", "\n", "area_dmap = hv.DynamicMap(make_area, streams=[bounds_stream])\n", "table_dmap = hv.DynamicMap(make_items, streams=[bounds_stream])\n", "\n", "(curve * scatter * area_dmap + table_dmap)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }