{
 "metadata": {
  "name": "",
  "signature": "sha256:0d193091f5c36750a28e02084044ef1234c172070cdf394afe89e2a7f7dd2465"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, arange, sin, cos\n",
      "import numpy as np"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from bokeh import load_notebook\n",
      "from bokeh.document import Document\n",
      "from bokeh.glyphs import Circle\n",
      "from bokeh.objects import (\n",
      "    Plot, DataRange1d, LinearAxis, Grid, ColumnDataSource, Glyph, PanTool, WheelZoomTool\n",
      ")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "x = arange(-2*pi, 2*pi, 0.1)\n",
      "y = sin(x)\n",
      "width = np.ones_like(x) * 0.02\n",
      "height = np.ones_like(x) * 0.2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "source = ColumnDataSource(data=dict(x=x, y=y,width=width, height=height))\n",
      "xdr = DataRange1d(sources=[source.columns(\"x\")])\n",
      "ydr = DataRange1d(sources=[source.columns(\"y\")])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "circle = Circle(x=\"x\", y=\"y\", fill_color=\"red\", size=5, line_color=\"black\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "glyph_renderer = Glyph(\n",
      "    data_source = source,\n",
      "    xdata_range = xdr,\n",
      "    ydata_range = ydr,\n",
      "    glyph = circle,\n",
      ")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pantool = PanTool(dimensions=[\"width\", \"height\"])\n",
      "zoomtool = WheelZoomTool(dimensions=[\"width\", \"height\"])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], min_border=80)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "xaxis = LinearAxis(plot=plot, dimension=0)\n",
      "yaxis = LinearAxis(plot=plot, dimension=1)\n",
      "xgrid = Grid(plot=plot, dimension=0, axis=xaxis) \n",
      "ygrid = Grid(plot=plot, dimension=1, axis=yaxis)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plot.renderers.append(glyph_renderer)\n",
      "plot.tools = [pantool,zoomtool]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "load_notebook(force=True)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import IPython.core.displaypub as displaypub\n",
      "from bokeh.embed import notebook_div\n",
      "displaypub.publish_display_data('bokeh', {'text/html': notebook_div(plot)})"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}