What are you trying to do?
I have multiple figures (each with some lines), sharing x-axis but not the y-axis. When my cursor hover on one figure, it will tell me the values(x & y-axis values). But Others have no tooltips. I want all figures show tooltips simultaneously when cursor hover any figure.
What have you tried that did NOT work as expected? If you have also posted this question elsewhere (e.g. StackOverflow), please include a link to that post.
I have searched internet, got almost no result. Can the Crosshair tool trigger hover points? - #2 by Bryan
import numpy as np
import bokeh
from bokeh.plotting import figure, show, output_notebook
from bokeh.models import Slider, HoverTool, CustomJS, ColumnDataSource
from bokeh.layouts import column
from bokeh.models import CustomJS, CrosshairTool
from bokeh.layouts import layout
output_notebook()
N = 100
x = np.arange(N) + np.random.random(size=N)
y = np.arange(N) * 0.5 + np.random.random(size=N)
source = ColumnDataSource(dict(x=x, y=y))
TOOLS="hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select,"
p = figure(tools=TOOLS, height=300, width=300)
l1_rnder = p.line(x='x', y='y', source=source)
p2 = figure(tools=TOOLS, height=300, width=300)
l2_rnder = p2.line(x='x', y='y', source=source)
p.add_tools(bokeh.models.HoverTool(show_arrow=True,
line_policy='next',
mode='vline',
renderers=[l1_rnder],
tooltips=[('X', '$x'),('Y', '$y')]))
p2.add_tools(bokeh.models.HoverTool(show_arrow=True,
line_policy='next',
mode='vline',
renderers=[l2_rnder],
tooltips=[('X', '$x'),('Y', '$y')]))
def addLinkedCrosshairs(plots):
crosshair = CrosshairTool(dimensions="height")
for p in plots:
p.add_tools(crosshair)
addLinkedCrosshairs([p, p2])
show(layout([p, p2]), notebook_handle=True)
Present outlook is as follows. Only one figure gives tooltips.