I am trying to customize the Hover Tool to display Column name, Index , and value for each line graph, however I can’t figure out how to access the column name and index value to display for each line graph. Is there a way to do this in Bokeh?
I have data that looks like this and will have more columns in the future.
Houston Chicago New York
2008 3561656 2712054 84846872
2009 3879058 2757302 87052104
2010 4047881 2687872 89292832
2011 4098648 2847405 87041208
2012 3996017 2995507 88945904
2013 3829361 2829287 87854568
2014 4029416 3211596 93676080
2015 4305298 3670746 100263208
2016 5217114 4317027 107957408
``
This is my code to create multiple line graphs on the same plot:
import pandas as pd
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import HoverTool,WheelZoomTool, PanTool, ResetTool
data = pd.read_csv('CITYTEST.csv', index_col =0)
print data
source = ColumnDataSource(data)
#This is not right...
hover = HoverTool(
tooltips=[
( 'City' , '@columns'),
( 'Year', '@index'),
( 'Numbers', '$y{0,0}')
]
)
tools = [PanTool(), WheelZoomTool(), ResetTool(), hover]
p = figure(plot_width=1100, plot_height=500, tools = tools)
Cities = list(data.columns.values)
for i in range(0,3):
p.line(x=data.index, y=data[Cities[i]], line_width = 2, legend = Cities[i])
p.yaxis.axis_label = 'Some Numbers'
p.xaxis.axis_label = 'Year'
show(p)
Is there a way I can change the hover tool to display City, Year, and value for each line in the graph separately?