
I have a bokeh gridplot and I want to connect the two subplots so that when I move the mouse on the upper plot, it will get the index of the point (based on x axis), and highlight the corresponding point in the lower plot.
How can I do that?
umap_source = ColumnDataSource(data=dict(x=umap_results[:,0], y=umap_results[:,1]))
hover_tool = HoverTool(callback=callback)
p1= figure(plot_width=500,
plot_height=200,
tools=[hover_tool,"xpan,crosshair,reset"])
p2= figure(plot_width=500,
plot_height=500,
tools="xpan,hover,reset")
p1.line(range(len(samples)), samples[:,0])
p2.scatter(umap_results[:,0],umap_results[:,1])
c2 = p2.circle(umap_results[0,0],umap_results[0,1],fill_color='red',radius=0.2)
callback = CustomJS(args=dict(s=umap_source,c2=c2), code="""
var geometry = cb_data['geometry'];
var x_data = geometry.x; // current mouse x position in plot coordinates
var u0 = s['data']['x'][Math.floor(x_data)];
var u1 = s['data']['y'][Math.floor(x_data)];
console.log("p=>" + x_data+":"+u0+","+u1); //monitors values in Javascript console
// and this is what I want to do:
c2['x']=u0;
c2['y']=u1;
""")
gp = gridplot(children=[[p1], [p2]])
bk_plotting.show(gp)


