#!/usr/bin/env python # coding: utf-8 # In[1]: from bokeh.models import HoverTool, ColumnDataSource from bokeh.io import output_notebook, show from bokeh.plotting import figure from bokeh.sampledata.autompg import autompg output_notebook() # In[2]: hover = HoverTool( tooltips=[ ("Vehicle", "@name, 19@yr"), ("MPG", "@mpg"), ("Engine", "@displ cu in @cyl cylinder @hp HP"), ] ) cmap = dict(zip([1,2,3], 'red green blue'.split())) omap = dict(zip([1,2,3], 'American European Asian'.split())) autompg['colors'] = [cmap[o] for o in autompg.origin] origin = [omap[o] for o in autompg.origin] p = figure(tools=[hover], width=800, height=400) p.circle('mpg', 'weight', color='colors', size=10, alpha=0.3, source=ColumnDataSource(autompg), legend='colors') show(p)