Boundsy

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


Title: BoundsY stream example

Description: A linked streams example demonstrating how to use BoundsY streams.

Dependencies Plotly

Backends Plotly, Bokeh

In [1]:
import numpy as np
import holoviews as hv
from holoviews import opts, streams

hv.extension('plotly')
In [2]:
xs = np.linspace(0, 1, 200)
ys = xs*(1-xs)
curve = hv.Curve((xs,ys))
scatter = hv.Scatter((xs,ys)).opts(size=1)

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)))

area_dmap = hv.DynamicMap(make_area, streams=[bounds_stream])
table_dmap = hv.DynamicMap(make_items, streams=[bounds_stream])

(curve * scatter * area_dmap + table_dmap)
Out[2]:

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