Bokeh Tutorial

00. Introduction and Setup

What is Bokeh

Bokeh is a Data Visualization library for

  • interactive visualization in modern browsers
  • standalone HTML documents, or server-backed apps
  • capable of expressive and verstatile graphics
  • can handle large, dynamic or streaming data
  • available from python (or Scala, or R, or Julia, or...)

And most importantly:

NO JAVASCRIPT REQUIRED

What can you do with Bokeh

In [1]:
# Standard imports 

from bokeh.io import output_notebook, show
output_notebook()
Loading BokehJS ...
In [2]:
# Plot a complex chart in a single line

from bokeh.charts import Histogram
from bokeh.sampledata.iris import flowers as data

hist = Histogram(data, values="petal_length", color="species", legend="top_right", bins=12)

show(hist)
In [3]:
# Build and serve beautiful web-ready interactive visualizations

import utils
p = utils.get_gapminder_plot()
show(p)
In [4]:
# Create and deploy interactive data applications

from IPython.display import IFrame
IFrame('http://demo.bokehplots.com/apps/sliders', width=900, height=500)
Out[4]:

How does it work

Getting set up

In [5]:
from IPython.core.display import Markdown
Markdown(open("README.md").read())
Out[5]:

Bokeh Tutorial

Setup

Clone or download the repo

First get local copies of the tutorial notebooks:

$ git clone https://github.com/bokeh/bokeh-notebooks.git

Or download from: https://github.com/bokeh/bokeh-notebooks/archive/master.zip

Install the dependencies

This tutorial has been tested on:

  • bokeh=0.12.0
  • pandas=0.18
  • ipython-notebook=4.0.4
  • ipywidgets=4.1.1

Other combinations may work also. Packages are available via PyPI and anaconda.org.

Installing with anaconda

Install anaconda

Anaconda should come with all the dependencies included, but you may need to update your versions.

Install with miniconda

Install miniconda.

Use the command line to create an environment and install the packages:

$ conda env create
$ source activate bokeh-notebooks

Run this from the tutorial directory where environment.yml lives.

Get the sample data

Bokeh has a sample data download that gives us some data to build demo visualizations. To get it run:

$ bokeh sampledata

Install datashader and holoviews (optional)

Optional tutorials 11 and 12 require the datashader and holoviews packages, respectively, which can be installed with:

$ conda install -c bokeh datashader
$ conda install -c holoviews/label/dev holoviews

Run Jupyter/IPython notebook

From this folder run jupyter notebook, and open the 00-intro.ipynb notebook.

$ jupyter notebook

Setup-test, run the next cell. Hopefully you should see output that looks something like this:

IPython - 5.1.0
Pandas - 0.18.1
Bokeh - 0.12.2

If this isn't working for you, see the README.md in this directory.

In [6]:
from IPython import __version__ as ipython_version
from pandas import __version__ as pandas_version
from bokeh import __version__ as bokeh_version
print("IPython - %s" % ipython_version)
print("Pandas - %s" % pandas_version)
print("Bokeh - %s" % bokeh_version)
IPython - 5.1.0
Pandas - 0.18.1
Bokeh - 0.12.2rc3
In [ ]: