Here is a minimal example of what I want to achieve
from bokeh.plotting import ColumnDataSource, figure, output_file, save
output_file("test_plot.html")
source = ColumnDataSource(data=dict(
x=[1,3],
y=[3,7],
label=['a','b']
))
TOOLTIPS = [ ("label", "@label")]
p = figure(plot_width=400, plot_height=400, tooltips=TOOLTIPS, title="plot")
p.circle('x', 'y', size=20,fill_alpha=0.5, source=source)
source = ColumnDataSource(data=dict(
x=[0],
y=[0],
info1 = ['info 1'],
info2 = ['info 2']
))
p.circle('x','y', size=10,fill_alpha=0.5, source=source)
save(p)
and I need to add a different TOOLTIPS to the scatter at (0,0), which can display info1 and info2.
You have to create the tools manually. Note that it will also display multiple tools on the toolbar.
from bokeh.models import HoverTool
from bokeh.plotting import ColumnDataSource, figure, save
source = ColumnDataSource(data=dict(x=[1, 3], y=[3, 7],
label=['a', 'b']))
p = figure(plot_width=400, plot_height=400, title="plot")
circle1 = p.circle('x', 'y', size=20, fill_alpha=0.5, source=source)
source = ColumnDataSource(data=dict(x=[0], y=[0],
info1=['info 1'], info2=['info 2']))
circle2 = p.circle('x', 'y', size=10, fill_alpha=0.5, source=source)
p.add_tools(HoverTool(renderers=[circle1],
tooltips=[('label', '@label')]),
HoverTool(renderers=[circle2],
tooltips=[('info1', '@info1'),
('info2', '@info2')]))
save(p)