In [3]:
import bokeh

In [4]:
bokeh.sampledata.download()


Creating ~/.bokeh directory
Creating /Users/srinathv/.bokeh/data directory
Using data directory: /Users/srinathv/.bokeh/data
Downloading: CGM.csv (1589982 bytes)
   1589982 [100.00%]
Downloading: US_Counties.zip (3182088 bytes)
   3182088 [100.00%]
Unpacking: US_Counties.csv
Downloading: unemployment09.csv (253301 bytes)
    253301 [100.00%]
Downloading: AAPL.csv (166698 bytes)
    166698 [100.00%]
Downloading: FB.csv (9706 bytes)
      9706 [100.00%]
Downloading: GOOG.csv (113894 bytes)
    113894 [100.00%]
Downloading: IBM.csv (165625 bytes)
    165625 [100.00%]
Downloading: MSFT.csv (161614 bytes)
    161614 [100.00%]
Downloading: WPP2012_SA_DB03_POPULATION_QUINQUENNIAL.zip (5148539 bytes)
   5148539 [100.00%]
Unpacking: WPP2012_SA_DB03_POPULATION_QUINQUENNIAL.csv
Downloading: gapminder_fertility.csv (64346 bytes)
     64346 [100.00%]
Downloading: gapminder_population.csv (94509 bytes)
     94509 [100.00%]
Downloading: gapminder_life_expectancy.csv (73243 bytes)
     73243 [100.00%]
Downloading: gapminder_regions.csv (7781 bytes)
      7781 [100.00%]

In [5]:
from bokeh.sampledata.glucose import data
(x, y) = (data.ix['2010-10-06'].index.to_series(), data.ix['2010-10-06']['glucose'])

from bokeh.plotting import figure, output_notebook, show
from bokeh.models import ColumnDataSource, Circle, HoverTool, CustomJS


output_notebook()


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-734c3d69e243> in <module>()
      3 
      4 from bokeh.plotting import figure, output_notebook, show
----> 5 from bokeh.models import ColumnDataSource, Circle, HoverTool, CustomJS
      6 
      7 

ImportError: cannot import name CustomJS

In [ ]:
# Basic plot setup
p = figure(
    width=750, 
    height=300, 
    x_axis_type="datetime", 
    outline_line_color=None, 
    tools="", 
    toolbar_location=None, 
    title='Hover over points on line'
)
p.line(x, y, line_dash="4 4", line_width=1, color='gray')

p.xaxis[0].axis_line_color = None
p.yaxis[0].axis_line_color = None
p.xgrid[0].grid_line_color = None
p.ygrid[0].grid_line_alpha =0.5
p.xaxis[0].major_label_text_color = 'gray'
p.xaxis[0].major_tick_line_color = 'gray'
p.yaxis[0].major_label_text_color = 'gray'
p.yaxis[0].minor_tick_line_color = None
p.yaxis[0].major_tick_line_color = None

# Add a circle, that is visible only when selected
source = ColumnDataSource({'x': x, 'y': y})
size = 20
invisible_circle = Circle(x='x', y='y', fill_color='gray', fill_alpha=0.05, line_color=None, size=size)
visible_circle = Circle(x='x', y='y', fill_color='firebrick', fill_alpha=0.5, line_color=None, size=size)
circle = p.add_glyph(source, invisible_circle, selection_glyph=visible_circle, nonselection_glyph=invisible_circle)

# Add a hover tool, that selects the circle
code = "source.set('selected', cb_data['index']);"
callback = CustomJS(args={'source': source}, code=code)
p.add_tools(HoverTool(tooltips=None, callback=callback, renderers=[circle], mode='hline'))

show(p)

In [ ]: