In [1]:
from bokeh.io import vplot, output_notebook, show
from bokeh.models import ColumnDataSource, DataRange1d, Grid, Plot, LinearAxis, Circle, HoverTool, TapTool
from bokeh.resources import INLINE
from bokeh.sampledata.autompg2 import autompg2 as mpg

output_notebook(resources=INLINE)


Loading BokehJS ...

In [2]:
source = ColumnDataSource(mpg)

plot = Plot(title=None, x_range= DataRange1d(), y_range=DataRange1d(), plot_height=200, responsive=True)

# Set up x & y axis
plot.add_layout(LinearAxis(), 'below')
yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

# Add Glyphs
cty_glyph = Circle(x="index", y="cty", fill_color="#396285", size=8, fill_alpha=0.5, line_alpha=0.5)
hwy_glyph = Circle(x="index", y="hwy", fill_color="#CE603D", size=8, fill_alpha=0.5, line_alpha=0.5)
cty = plot.add_glyph(source, cty_glyph)
hwy = plot.add_glyph(source, hwy_glyph)

# Add the tools
tooltips = [
    ("Manufacturer", "@manufacturer"),
    ("Model", "@model"),
    ("Year", "@year"),
]
cty_hover_tool = HoverTool(renderers=[cty], tooltips=tooltips)
hwy_hover_tool = HoverTool(renderers=[hwy], tooltips=tooltips)
cty_tap_tool = TapTool(renderers=[cty])
hwy_tap_tool = TapTool(renderers=[hwy])
plot.add_tools(cty_hover_tool, hwy_hover_tool, cty_tap_tool, hwy_tap_tool)

show(plot)


Out[2]:

<Bokeh Notebook handle for In[2]>


In [ ]: