I have a large dataset that I want datashade and then datashade a subset based on the lasso_select. This is very similar to an example at
except that I want to lasso_select from a datashaded scatter plot.
I would be interested in finding a way to fetch the lasso_select polygon to intersect that with the scatte upfron of datashade for hte dynamic map.
import numpy as np import holoviews as hv from holoviews import opts from holoviews import streams from holoviews.operation.datashader import datashade hv.extension('bokeh') opts.defaults(opts.Scatter(tools=['box_select', 'lasso_select'])) # Declare some points points = hv.Scatter(np.random.randn(1000,2 )) ds_static = datashade(points).opts(tools=['box_select', 'lasso_select'], active_tools=['box_select']) # Declare points as source of selection stream selection = streams.Selection1D(source=ds_static) # Write function that uses the selection indices to slice points and compute stats def selected_info(index): selected = points.iloc[index] print(selected) if index: label = 'Mean x, y: %.3f, %.3f' % tuple(selected.array().mean(axis=0)) else: label = 'No selection' return selected.relabel(label).opts(color='red') # Combine points and DynamicMap ds_dynamic = datashade(hv.DynamicMap(selected_info, streams=[selection]), x_sampling=.1, y_sampling=.1 ) ds_static + ds_dynamic
Any suggestions please?