Boundsy

Title
YBounds stream example
Description
A linked streams example demonstrating how to use YBounds streams.
Backends
Bokeh
Tags
streams, linked, interactive
In [ ]:
import numpy as np
import holoviews as hv
from holoviews import streams
hv.extension('bokeh')
In [ ]:
%%opts Curve[tools=['ybox_select']]

xs = np.linspace(0, 1, 200)
ys = xs*(1-xs)
curve = hv.Curve((xs,ys))

bounds_stream = streams.BoundsY(source=curve,boundsy=(0,0))

def make_area(boundsy):
    return hv.Area((xs, np.minimum(ys, boundsy[0]), np.minimum(ys, boundsy[1])), vdims=['min','max'])


def make_items(boundsy):
    times = ["{0:.2f}".format(x) for x in sorted(np.roots([-1,1,-boundsy[0]])) + sorted(np.roots([-1,1,-boundsy[1]]))]
    return hv.ItemTable(sorted(zip(['1_entry', '2_exit', '1_exit', '2_entry'], times)))


curve * hv.DynamicMap(make_area, streams=[bounds_stream]) + hv.DynamicMap(make_items, streams=[bounds_stream])

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