I'm plotting and selecting points with Holoviews
import holoviews as hv
import numpy as np
N = 100
x = np.random.normal(size=N)
y = np.random.normal(size=N)
points = hv.Points((x, y))
selection = hv.streams.Selection1D(points)
points.options(tools=["lasso_select"])
How can I get the indices selected from lasso as a vector in my Python environment for further analysis?
There's ample documentation, start for example here: http://holoviews.org/reference/streams/bokeh/Selection1D_tap.html
Basically, you need to link your selection stream to the holoviews element through a DynamicMap. Then,
selection
will hold your selected indices.I adapted the following example from the docs:
Then do some selection. Now
print(selection)
will hold the selected indices