Add tooltip to elements example
add accoding to
tiny bit of code cleanup (pylint)
import pandas as pd
-from bokeh.models import ColumnDataSource, LabelSet
+from bokeh.models import ColumnDataSource, LabelSet, HoverTool
from bokeh.plotting import figure, show, output_file
from bokeh.sampledata.periodic_table import elements
@@ -19,10 +19,18 @@ high= max(melting_points)
melting_point_inds = [int(10*(x-low)/(high-low)) for x in melting_points] #gives items in colors a value from 0-10
elements['melting_colors'] = [palette[i] for i in melting_point_inds]
-TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
TITLE = "Density vs Atomic Weight of Elements (colored by melting point)"
-
-p = figure(tools=TOOLS, toolbar_location="above", logo="grey", plot_width=1200, title=TITLE)
+tools = "pan,wheel_zoom,box_zoom,reset,save".split(',')
+hover = HoverTool(tooltips=[
+ ("name", "@name"),
+ ("symbol:", "@symbol"),
+ ("density", "@density"),
+ ("atomic weight", "@{atomic mass}"),
+ ("melting point", "@{melting point}")
+])
+tools.append(hover)
+
+p = figure(tools=tools, toolbar_location="above", logo="grey", plot_width=1200, title=TITLE)
p.background_fill_color = "#dddddd"
p.xaxis.axis_label = "atomic weight (amu)"
p.yaxis.axis_label = "density (g/cm^3)"
