PointerXY#

Download this notebook from GitHub (right-click to download).


Title
Simple pointer example
Description
A linked streams example demonstrating how us a PointerXY stream to reveal more information about coordinate.
Backends
Bokeh
Tags
streams, linked, pointer, interactive
import numpy as np
import holoviews as hv
from holoviews import streams
hv.extension('bokeh')
Y,X=(np.mgrid[0:100, 0:100]-50.)/20.
img = hv.Image(np.sin(X**2+Y**2))

# Declare pointer stream initializing at (0, 0) and linking to Image
pointer = streams.PointerXY(x=0, y=0, source=img)

# Define function to draw cross-hair and report value of image at location as text
def cross_hair_info(x, y):
    text = hv.Text(x+0.05, y, '%.3f'% img[x,y], halign='left', valign='bottom')
    return hv.HLine(y) * hv.VLine(x) * text

# Overlay image and cross_hair_info
img * hv.DynamicMap(cross_hair_info, streams=[pointer])
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).