{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### **Title**: RangeXY stream example\n", "\n", "**Description**: A linked streams example demonstrating how to use multiple Selection1D streams on separate Points objects.\n", "\n", "**Dependencies** Plotly\n", "\n", "**Backends** [Plotly](./RangeXY.ipynb), [Bokeh](../bokeh/RangeXY.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import holoviews as hv\n", "\n", "hv.extension('plotly')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Define an image\n", "Y, X = (np.mgrid[0:100, 0:100]-50.)/20.\n", "img = hv.Image(np.sin(X**2+Y**2))\n", "\n", "def selected_hist(x_range, y_range):\n", " # Apply current ranges\n", " obj = img.select(x=x_range, y=y_range) if x_range and y_range else img\n", "\n", " # Compute histogram\n", " return hv.operation.histogram(obj)\n", "\n", "# Define a RangeXY stream linked to the image \n", "rangexy = hv.streams.RangeXY(source=img)\n", "\n", "# Adjoin the dynamic histogram computed based on the current ranges\n", "img << hv.DynamicMap(selected_hist, streams=[rangexy])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }