I am very new to Holoviews/DataShader/Bokeh, analyzing these libraries for a research project. I have a requirement to plot on 1 billion plots in a scatter plot and then on lasso of the plot capture the selected points , preferably the geometry of the selection.
I did come across the example -- http://holoviews.org/reference/streams/bokeh/Selection1D_points.html We need to link your selection stream to the holoviews element through a DynamicMap. Then, selection will hold your selected indices.
Below is what I have tried and have been successful in getting the geometry but the plot gets very slow and if its more and 1 million points I start getting browser memory issues and also the lasso is very very slow.
I have a dataframe with 3 columns x, y , pred
And this code gives me the plot
points = hv.Points(df)
datashaded = hd.datashade(points, aggregator=ds.count_cat('pred')).redim.range(x=(xmin, xmax), y=(ymin, ymax)).opts(
width=600, height=600, tools=['box_select', 'lasso_select', 'hover'])
# Declare points as source of selection stream
lasso = streams.Lasso(source=points)
def lassocallback(geometry):
if geometry is not None:
with open('coordinates.txt', 'w') as f:
np.savetxt(f, geometry)
return points
# Final Plot
datashaded + hv.DynamicMap(lassocallback, streams=[lasso]).opts(width=600,height=600,tools=['box_select', 'lasso_select','hover'])
Also I get two plots as a result, as hv.DynamicMap alone won't show the points how do I just get a single plot for this.