Code Monkey home page Code Monkey logo

bokeh's Introduction

Bokeh

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.

A related project is Pandas, whose DataFrame objects are directly used by Bokeh. Bokeh will also interface with the NDTable objects in Blaze.

Technology

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.

Dependencies

For the initial prototype, Bokeh is implemented as a wrapper on top of the Chaco plotting system, and displays its output using Chaco. This will change as we implement the Javascript/HTML backend.

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.

  • Chaco
  • Traits
  • Pandas
  • [flask]
  • [redis]
  • [requests]
  • [gevent-websocket]
  • [gevent]
  • [pandas]

Installation

After installing the dependencies (chaco, etc.), run the following:

git clone git://github.com/ContinuumIO/Bokeh.git
cd Bokeh
python setup.py install

The setup.py will automatically grab the latest compiled javascript from github, so you don't need coffeescript in order to use Bokeh.

Status

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, and publish to the web via a few mechanisms.

  • Bokeh can output static html, which you can load into a browser
  • Bokeh can output static html to the ipython notebook
  • Bokeh can output static html to the ipython notebook, AND connect the notebook to the bokeh web server
  • by navigating to http://localhost:5006/bokeh, you can view Bokeh plots as they are pushed out via websockets by the webserver

Static html dump based web plotting examples

  • $ python facetgrid.py in tests/web/.
  • open up the generated grid.html in a web browser.
  • open up bokehnotebook.ipynb in the ipython notebook, execute the cells.

Server Based Web Plotting Examples

  • start a redis-server anywhere, using $ redis-server &
  • execute $ python startlocal.py in a terminal, this will start a webserver which will block the terminal
  • execute $ python pandas_example.py in examples/ This will make a few plots.
  • navigate to http://localhost:5006/bokeh. The bokeh client plots to named plot namespaces, called 'documents'. You should see a list of documents on this page in an accordion view, clicking on one should load the plots for that document
  • To do the same plots in an ipython notebook, open up an ipython notebook. open up cars.ipynb. Execute that notebook.

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.

Developing Bokeh

Coffeescript

We're developing most of the javascript using coffeescript, in the bokehjs github repository which has been included as a subtree. To develop Bokeh you will need to install coffeescript, which depends on node.js. I recommend using npm -g to install coffeescript globally.

Hem

We're using our own fork of hem to manage the build process.
Please clone this repo: https://github.com/ContinuumIO/hem. 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 $ python startlocaldebug.py. The debug webserver is configured to ask the hem server for compiled javascript, rather than read the pre-compiled js off of disk.
  • For the embedded plotting examples, or the production server, you will need to compile the js yourself,
    • $ hem build -d, will build the Bokeh application.js file
    • $ hem build -d -s slug.notebook.json will build bokehnotebook.js, which is used for all the notebook examples
    • the -d option will prevent hem from uglifying the js, which breaks the notebook export at the moment.

bokeh's People

Contributors

certik avatar paddymul avatar spencerogden avatar tebeka avatar yesimon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.