Book Image

IPython Interactive Computing and Visualization Cookbook

By : Cyrille Rossant
Book Image

IPython Interactive Computing and Visualization Cookbook

By: Cyrille Rossant

Overview of this book

Table of Contents (22 chapters)
IPython Interactive Computing and Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating interactive web visualizations with Bokeh


Bokeh is a library for creating rich interactive visualizations in a browser. Plots are designed in Python, and they are entirely rendered in the browser. In this recipe, we will learn how to create and render interactive Bokeh figures in the IPython notebook.

Getting ready

Install Bokeh by following the instructions on the website at http://bokeh.pydata.org. In principle, you can just type pip install bokeh in a terminal. On Windows, you can also download the binary installer from Chris Gohlke's website at http://www.lfd.uci.edu/~gohlke/pythonlibs/#bokeh.

How to do it…

  1. Let's import NumPy and Bokeh. We need to call the output_notebook() function in order to tell Bokeh to render plots in the IPython notebook:

    In [1]: import numpy as np
            import bokeh.plotting as bkh
            bkh.output_notebook()
  2. We create some random data:

    In [2]: x = np.linspace(0., 1., 100)
            y = np.cumsum(np.random.randn(100))
  3. Let's draw a curve:

    In [3]: bkh.line(x...