hover - Python bokeh apply hovertools only on model not on figure -
i want have scatter plot , (base)line on same figure. , want use hovertool
on circles of scatter not on line. possible?
with code below tooltips index: 0
, (x, y): (???, ???)
when hover on line (any part of line). index: 0
data in source
totally different ((x, y): (1, 2)
)...
df = pd.dataframe({'a':[1, 3, 6, 9], 'b':[2, 3, 5, 8]}) bokeh.models import hovertool import bokeh.plotting 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')
thank you!!
to limit renderers want hovertool active on (by default it's active on all) can either set name
attr on glyphs, specify names want hovertool active on:
p.circle('a', 'b', size=10, name='circle', source=source) hover = hovertool(names=['circle'])
or can add renderers hovertool.
circle = p.circle('a', 'b', size=10, source=source) hover = hovertool(renderers=['circle'])
Comments
Post a Comment