Tap tool not working with linked brushing

Hi, while I can get rectangle or lasso select to work with linked brushing, it does not work with the tap tool. If a point exists in both plots, I’d like it to be selected in both plots and the rest made more transparent. e.g.

import numpy as np
import pandas as pd
import panel as pn
import holoviews as hv
import hvplot.pandas

hv.opts.defaults(hv.opts.Points(nonselection_alpha=0.4))

from bokeh.sampledata.autompg import autompg
autompgi = autompg.interactive()

ls = hv.link_selections.instance()

def plots():
    return ls(autompg.hvplot.scatter(x='mpg',y='cyl',tools=['box_select', 'tap','lasso_select'],width=500)\
              +autompg.hvplot.scatter(x='displ',y='cyl',tools=['box_select', 'tap','lasso_select'],width=500))

   
pn.Column(
    pn.Row(select_column1,select_column2),
    plots 
)

I seem to have found a way around this, with a couple of gremlins. By adding an ‘uid’ column identical to the index I can pass that to index_cols. I want to select various other columns for hover_cols, but it seems they can’t contain any used for index_cols. Also, the plots must be defined within the call to ls, if defined outside columns not pertaining to the plot are dropped (i.e the ‘uid’ column).

import numpy as np
import pandas as pd
import panel as pn
import holoviews as hv
import hvplot.pandas

hv.opts.defaults(hv.opts.Points(nonselection_alpha=0.4))
hv.Store.set_current_backend('bokeh') # panel doesn't work with plotly?

from bokeh.sampledata.autompg import autompg
autompg['uid'] = autompg.index

# hover_cols can't include those used for index_cols in linked selection?
all_cols = ['mpg', 'cyl', 'displ', 'hp', 'weight', 'accel', 'yr', 'origin', 'name'] 


ls = hv.link_selections.instance()

def plots():
    hcols = list(autompg.columns)
    return ls(autompg.hvplot.scatter(x='mpg',y='cyl',
                                     tools=['box_select', 'tap','lasso_select',],
                                     hover_cols=all_cols,
                                     width=500)
              +autompg.hvplot.scatter(x='displ',y='cyl',
                                      tools=['box_select', 'tap','lasso_select'],
                                      hover_cols=all_cols,
                                      width=500),
             index_cols=['uid'],unselected_alpha=0.1,selected_color='#00ff00',unselected_color='#0000ff')
   
pn.Column(
    # pn.Row(select_column1,select_column2),
    plots 
)
1 Like