Is there a way to adjust the alpha or color of unselected or selected points in a Scatter plot that is linked to another plot when the link is created with DataLink? Or, is there a way to create javascript based linked brushing and adjust the alpha of unselected points or color of selected points?
Making these types of styling adjustments with with python backed linked brushing is discussed in the docs, but I haven’t found where there are options to adjust styling for javascript backed linked brushing, if there are.
I’d like to use the javascript backed brushing because I often save my notebooks that use this functionality as html files and would like the linked brushing to work in that format.
Here is a minimal example. This replicates the current plots I have, but doesn’t show so well how hard it is to see the difference between the selected and unselected points in the bottom plot in my real plots. Looking at my real plots closer, I think the issue there is overplotting. The unselected points are overlapping and therefore appear as a higher alpha until I zoom in. Given that is the real issue, I think the solution I’m looking for is a way to make the selected points a different color.
import pandas as pd
import numpy as np
import holoviews as hv
from holoviews import opts
from holoviews.plotting.links import DataLink
hv.extension('bokeh', logo=False)
df = pd.DataFrame({'x':np.arange(100), 'y':np.arange(100) * 2, 'datetime':pd.date_range('2/1/24 12:00', freq='1min', periods=100)})
df2 = df.loc[0:30, :]
scatter1 = hv.Scatter(df2, ['x'], ['y'])
scatter2 = hv.Scatter(df2, ['datetime'], ['y'])
curve1 = hv.Curve(df, 'datetime', ['y', 'x']).opts(line_color='gray', line_width=1, line_alpha=0.4)
dlink = DataLink(scatter1, scatter2)
(scatter1 + curve1 * scatter2).opts(
opts.Scatter(tools=['box_select', 'lasso_select'])).cols(1)