from bokeh.models import HoverTool
from bokeh.charts import Line, Scatter, vplot, hplot, show, output_file, defaults
import pandas as pd
from bokeh.sampledata.degrees import xyvalues

defaults.width = 500
defaults.height = 300

xyvalues = xyvalues[['Biology', 'Business', 'Computer Science', "Year"]]
xyvalues = pd.melt(xyvalues, id_vars=['Year'],
                   value_vars=['Biology', 'Business', 'Computer Science'],
                   value_name='Count', var_name='Degree')

TOOLS='box_zoom,box_select,hover,crosshair,resize,reset'
output_file("lines.html", title="line.py example")
vline = Line(xyvalues, y='Count', color='Degree', title="Lines VLine", ylabel='measures',
             tools=TOOLS)
hline = Line(xyvalues, y='Count', color='Degree', title="Lines HLine",
             ylabel='measures', tools=TOOLS)
int_vline = Line(xyvalues, y='Count', color='Degree', title="Lines VLine Interp",
                 ylabel='measures', tools=TOOLS)
int_hline = Line(xyvalues, y='Count', color='Degree', title="Lines HLine Interp",
                 ylabel='measures', tools=TOOLS)

scatter_point = Scatter(xyvalues, x='Year', y='Degree', title="Scatter mouse",
                        ylabel='measures', legend=True, tools=TOOLS)
# scatter = Scatter(svalues, title="Scatter V Line", ylabel='measures',
#              legend=True, tools=TOOLS)
#
# int_point_line = Line(xyvalues, title="Lines Mouse Interp.", ylabel='measures',
#              tools=TOOLS)
# point_line = Line(xyvalues, title="Lines Mouse", ylabel='measures',
#              tools=TOOLS)


hhover = hline.select(dict(type=HoverTool))
hhover.mode = 'hline'
hhover.line_policy = 'next'

vhover = vline.select(dict(type=HoverTool))
vhover.mode = 'vline'
vhover.line_policy = 'nearest'

int_hhover = int_hline.select(dict(type=HoverTool))
int_hhover.mode = 'hline'
int_hhover.line_policy = 'interp'

int_vhover = int_vline.select(dict(type=HoverTool))
int_vhover.mode = 'vline'
int_vhover.line_policy = 'interp'

# iphover = int_point_line.select(dict(type=HoverTool))
# iphover.mode = 'mouse'
# iphover.line_policy = 'interp'
#
# tphover = point_line.select(dict(type=HoverTool))
# tphover.mode = 'mouse'
#
# shover = scatter.select(dict(type=HoverTool))
# shover.mode = 'vline'
#
# shoverp = scatter_point.select(dict(type=HoverTool))
# shoverp.mode = 'mouse'

TOOLTIPS = [
    ("y", "$~y"),
    ("x", "$~x"),
]

int_vhover.tooltips = int_hhover.tooltips = TOOLTIPS
# tphover.tooltips = iphover.tooltips = TOOLTIPS
# shover.tooltips = shoverp.tooltips = TOOLTIPS
vhover.tooltips = hhover.tooltips = TOOLTIPS

show(
    vplot(
        hplot(hline, vline),
        hplot(int_hline, int_vline),
        hplot(scatter_point)
        # hplot(int_point_line, point_line),
        # hplot(scatter_point, scatter),
    )
)

@@ -583,16 +583,17 @@
 ample%22)%0A
+%0A
 vline = 
@@ -700,16 +700,17 @@
 =TOOLS)%0A
+%0A
 hline = 
@@ -813,24 +813,25 @@
 ools=TOOLS)%0A
+%0A
 int_vline = 
@@ -949,16 +949,17 @@
 =TOOLS)%0A
+%0A
 int_hlin
@@ -1133,38 +1133,30 @@
  y='
-Degree', title=%22Scatter mouse%22
+Count', color='Degree'
 ,%0A  
@@ -1168,32 +1168,55 @@
                 
+ title=%22Scatter mouse%22,
  ylabel='measure
@@ -1223,32 +1223,56 @@
 s', legend=True,
+%0A                       
  tools=TOOLS)%0A# 
@@ -1269,18 +1269,16 @@
 =TOOLS)%0A
-# 
 scatter 
@@ -1291,16 +1291,72 @@
 ter(
-s
+xy
 values,
+ x='Year', y='Count', color='Degree',%0A                 
  tit
@@ -1394,31 +1394,16 @@
 asures',
-%0A#             
  legend=
@@ -1421,20 +1421,17 @@
 =TOOLS)%0A
-#%0A# 
+%0A
 int_poin
@@ -1445,32 +1445,91 @@
 = Line(xyvalues,
+ x='Year', y='Count', color='Degree',%0A                     
  title=%22Lines Mo
@@ -1556,39 +1556,24 @@
 ='measures',
-%0A#             
  tools=TOOLS
@@ -1574,18 +1574,17 @@
 =TOOLS)%0A
-# 
+%0A
 point_li
@@ -1602,16 +1602,71 @@
 yvalues,
+ x='Year', y='Count', color='Degree',%0A                 
  title=%22
@@ -1701,23 +1701,8 @@
 es',
-%0A#             
  too
@@ -2132,18 +2132,16 @@
 nterp'%0A%0A
-# 
 iphover 
@@ -2186,18 +2186,16 @@
 rTool))%0A
-# 
 iphover.
@@ -2209,18 +2209,16 @@
 'mouse'%0A
-# 
 iphover.
@@ -2240,20 +2240,17 @@
 interp'%0A
-#%0A# 
+%0A
 tphover 
@@ -2291,18 +2291,16 @@
 rTool))%0A
-# 
 tphover.
@@ -2314,20 +2314,17 @@
 'mouse'%0A
-#%0A# 
+%0A
 shover =
@@ -2357,26 +2357,24 @@
 HoverTool))%0A
-# 
 shover.mode 
@@ -2387,12 +2387,9 @@
 ne'%0A
-#%0A# 
+%0A
 shov
@@ -2437,18 +2437,16 @@
 rTool))%0A
-# 
 shoverp.
@@ -2566,18 +2566,16 @@
 OOLTIPS%0A
-# 
 tphover.
@@ -2613,18 +2613,16 @@
 OOLTIPS%0A
-# 
 shover.t
@@ -2799,39 +2799,8 @@
     
- hplot(scatter_point)%0A        #
  hpl
@@ -2842,10 +2842,8 @@
     
- #
  hpl

Fix hover span example.