In the code below I would like to know what to put in the place of the "????" so that the hover tool will show the name of the series (in this example either "series 1" or "series 2")
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import HoverTool, ColumnDataSource
output_notebook()
hover = HoverTool()
hover.tooltips=[("series name","????")]
f = figure(tools=[hover])
f.line([1,2,3],[2,1,5],legend="series 1")
f.line([1,2,3],[1,7,2],legend="series 2")
show(f)
I know you can do the following to make this work (see In Bokeh, how do I add tooltips to a Timeseries chart (hover tool)?). However I am embedding the plots in an HTML file that will have many data points per plot and many plots in the file so I am interested in minimizing the size of the data source that gets embedded in the HTML file.
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import HoverTool, ColumnDataSource
output_notebook()
hover = HoverTool()
hover.tooltips=[("series name","@legend")]
f = figure(tools=[hover])
data1 = ColumnDataSource({"x":[1,2,3], "y":[2,1,5], "legend":["series 1"]*3})
data2 = ColumnDataSource({"x":[1,2,3], "y":[1,7,2], "legend":["series 2"]*3})
f.line("x","y",source=data1, legend="series 1")
f.line("x","y",source=data2, legend="series 2")
show(f)