Python bokeh apply hovertools only on model not on figure
<p>I want to have a scatter plot and a (base)line on the same figure. And I want to use <code>HoverTool</code> only on the circles of scatter but not on the line. Is it possible?</p>

<p>With the code below I get tooltips with <code>index: 0</code> and <code>(x, y): (???, ???)</code> when I hover on the line (any part of the line). But the <code>index: 0</code> data in <code>source</code> is totally different (<code>(x, y): (1, 2)</code>)...</p>

<pre><code>df = pd.DataFrame({'a':[1, 3, 6, 9], 'b':[2, 3, 5, 8]})

from bokeh.models import HoverTool
import bokeh.plotting as bplt

TOOLS = ['box_zoom', 'box_select', 'wheel_zoom', 'reset', 'pan', 'resize', 'save']

source = bplt.ColumnDataSource(data=df)
hover = HoverTool(tooltips=[("index", "$index"), ("(x, y)", "(@a, @b)")])

p = bplt.figure(plot_width=600, plot_height=600, tools=TOOLS+[hover],
    title="My sample bokeh plot", webgl=True)

p.circle('a', 'b', size=10, source=source)

p.line([0, 10], [0, 10], color='red')

bplt.save(p, 'c:/_teszt.html')
</code></pre>

<p>Thank you!!</p>

<p>To limit which renderers you want the HoverTool is active on (by default it's active on all) you can either set a <code>name</code> attr on your glyphs, then specify which names you want your HoverTool to be active on:</p>

<pre><code>p.circle('a', 'b', size=10, name='circle', source=source)
hover = HoverTool(names=['circle'])
</code></pre>

<p>docs: <a href="http://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool.names" rel="nofollow">http://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool.names</a></p>

<p>or you can add the renderers to the HoverTool.</p>

<pre><code>circle = p.circle('a', 'b', size=10, source=source)
hover = HoverTool(renderers=['circle'])
</code></pre>

<p>docs: <a href="http://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool.renderers" rel="nofollow">http://bokeh.pydata.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool.renderers</a></p>

python hover tooltip bokeh