Hi,
I have a graph that has a number of lines and each line has been given a name.
When I hover over a line, is it possible to access the name of the line in the tooltip, without hardcoding it into the tooltip?
For example:
import sys
import os
import bokeh
import pandas as pd
from collections import OrderedDict
bokeh.io.output_notebook()
x = [0,1,2,3,4]
y1 = [0, 3.5, 8, 4, 5]
y2 = [100, 110, 200, 90, 30.5]
df = pd.DataFrame(data={‘x’:x, ‘y1’:y1, ‘y2’:y2})
f = bokeh.plotting.figure(plot_width=900, plot_height=400)
ds = bokeh.models.ColumnDataSource(df)
line1 = f.line(‘x’, ‘y1’, source=ds, name=‘line1’, color=‘blue’)
line2 = f.line(‘x’, ‘y2’, source=ds, name=‘line2’, color=‘red’)
htool = bokeh.models.HoverTool(mode=‘mouse’, line_policy=‘interp’, tooltips=OrderedDict([(‘x’, ‘@x’), (‘Mouse y’, ‘y'), ('Value:', '~y’), (‘Line Name:’, ‘@NAME’)]))
f.add_tools(htool)
bokeh.io.show(f)
``
Is there some parameter that can be added to the tooltip to display ‘line1’ or ‘line2’ when the user mouses over one of the lines?
Also, I have seen code snippets where people use $~y in the tooltip (the tilde). I cannot see documentation about that anywhere. It seems to display the actual value of the line or marker, but am I correct in saying that?
Thanks,
Adrian.