Bokeh (pronounced boh-Kay) is an implementation of Grammar of Graphics for Python, that also supports the customized rendering flexibility of Protovis and d3. Although it is a Python library, its primary output backend is HTML5 Canvas.
There are many excellent plotting packages for Python, but they generally do not optimize for the particular needs of statistical plotting (easy faceting, bulk application of aesthetic and visual parameters across categorical variables, pleasing default color palettes for categorical data, etc.). The goal of Bokeh is to provide a compelling Python equivalent of ggplot in R.
Bokeh has a function-oriented interface that closely resembles ggplot. These functions can be used interactively from the Python prompt, or from within a script (a la Matplotlib). Behind the scenes, these functions construct a scenegraph and data transformation pipeline that consists of nodes which can export their state into JSON.
The JSON representation of the graphic is then embedded in an HTML document which also contains the Bokeh JS runtime. This runtime is built on a port of Protovis to HTML5 Canvas, and consists of some higher-level canned plot layouts built on top of the Protovis framework.
You can install the following with easy_install, "pip install", or they may be available for your Linux system via the system package management. If you are using a distribution like Anaconda Community Edition, Enthought Python Distribution, or Python(X,Y), then you already have most of them installed.
After installing the dependencies (chaco, etc.), run the following:
git clone git://github.com/ContinuumIO/Bokeh.git cd Bokeh pip install .
Bokeh was started in March 2012, and still remains in the experimental/prototype stage. It is under active development by contributors at Continuum Analytics, and with the recent award of a grant from DARPA, we are able to devote more resources into it, along with collaborators from Indiana University.
Web based plotting
Bokeh can currently output to chaco, as well as dumping html, or interfacing with our bokeh web server, which will push plots out to a browser window using websockets. The following examples assume you have bokeh installed
Server Based Web Plotting Examples
- start a redis-server anywhere, using
$ redis-server &
- install the bokeh module
$ python setup.py develop
$ python startlocal.py
- navigate to
$ python examples/webplot_example.py
Static html dump based web plotting examples
$ python tests/web/facetgrid.py
- open up the generated
grid.htmlin a web browser
What Does the Name "Bokeh" Mean?
"Bokeh" is a photography term for the aesthetic quality of blurring of an image's background, to focus attention on a foreground subject.
We're using our own fork of hem to manage the build process.
Please clone this repo: https://github.com/ContinuumIO/hem as a subdirectory of the Bokeh repo. hem will compile coffeescript, combine js files, and support node.js require syntax on the client side
install it by executing
$ sudo npm link inside the hem repo.
This will link hem to your working copy so you get hem changes as we push it out
- Inside bokeh/server of the Bokeh repo, execute
$ hem server &. The hem server will serve up coffeescript, compiling them on the fly.
- If you are developing Bokeh, you should use the debug webserver.
start it by executing
- For the embedded plotting examples, or the production server, you will
need to compile the js yourself, by executing
$ hem build -d, the
-doption will prevent hem from uglifying the js, which breaks the notebook export at the moment.