{
 "metadata": {
  "name": "",
  "signature": "sha256:f6b9b5f2e6102fcd8aca3a75bff66637feed340e41280d01260a74052eddfee4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, arange, sin, cos, ones_like"
     ],
     "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, 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 = ones_like(x) * 0.02\n",
      "height = 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": [
      "plot = Plot(x_range=xdr, y_range=ydr, min_border=80)"
     ],
     "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": [
      "plot.add_glyph(source, xdr, ydr, circle)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "xaxis = LinearAxis()\n",
      "plot.add_layout(xaxis, 'below')\n",
      "\n",
      "yaxis = LinearAxis()\n",
      "plot.add_layout(yaxis, 'left')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker) )\n",
      "plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plot.add_tools(PanTool(), WheelZoomTool())"
     ],
     "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",
      "from bokeh.utils import publish_display_data\n",
      "data = {'text/html': notebook_div(plot)}\n",
      "publish_display_data(data)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}