Following the Linked brushing user guide, I wanted to add widget interactivity as follow:
import holoviews as hv
from holoviews.selection import link_selections
from bokeh.sampledata.autompg import autompg
from holoviews.util.transform import dim
import panel as pn
import numpy as np
hv.extension('bokeh', 'plotly', width=100)
hv.Store.set_current_backend('plotly')
ds = hv.Dataset(autompg)
sel = link_selections.instance(
selected_color='#bf0000', unselected_color='#ff9f9f', unselected_alpha=1
)
########### Widget added here
w_origin = pn.widgets.Select(name='agent', options=np.unique(ds['origin']).tolist())
scatter1 = hv.Scatter(ds, 'weight', 'accel')
scatter2 = hv.Scatter(ds, 'mpg', 'displ')
scatter3d = hv.Scatter3D(ds, ['mpg', 'hp', 'weight'])
table = hv.Table(ds, ['name', 'origin', 'yr'], 'mpg')
sel(
scatter1 + scatter2 + scatter3d + table,
# Widget applied here
selection_expr=((dim('origin')==w_origin) & (dim('mpg') >16))
).cols(2)
The only code change is the selection of the “origin” with a select widget, but no widget appears.
I eventualy would like to add a date selector etc…
PS: base script does not work for me either, the selection on one plot is not reflected on the others.