{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import time\n",
    "from numpy import pi, cos, sin, linspace, roll, zeros_like\n",
    "from bokeh.plotting import cursession, figure, show, output_notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "N = 50 + 1\n",
    "r_base = 8\n",
    "theta = linspace(0, 2*pi, N)\n",
    "r_x = linspace(0, 6*pi, N-1)\n",
    "rmin = r_base - cos(r_x) - 1\n",
    "rmax = r_base + sin(r_x) + 1\n",
    "colors = [\n",
    "    \"FFFFCC\", \"#C7E9B4\", \"#7FCDBB\", \"#41B6C4\", \"#2C7FB8\", \n",
    "    \"#253494\", \"#2C7FB8\", \"#41B6C4\", \"#7FCDBB\", \"#C7E9B4\"\n",
    "] * 5\n",
    "cx = cy = zeros_like(rmin)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "*To run these examples you must execute the command `python bokeh-server` in the top-level Bokeh source directory first.*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook(url=\"default\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(x_range=[-11, 11], y_range=[-11, 11])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p.annular_wedge(cx, cy, rmin, rmax, theta[:-1], theta[1:],\n",
    "                fill_color = colors, line_color=\"black\", name=\"aw\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "renderer = p.select(dict(name=\"aw\"))[0]\n",
    "ds = renderer.data_source\n",
    "show(p)\n",
    "while True:\n",
    "    rmin = ds.data[\"inner_radius\"]\n",
    "    rmin = roll(rmin, 1)\n",
    "    ds.data[\"inner_radius\"] = rmin\n",
    "    \n",
    "    rmax = ds.data[\"outer_radius\"]\n",
    "    rmax = roll(rmax, -1)\n",
    "    ds.data[\"outer_radius\"] = rmax\n",
    "    \n",
    "    cursession().store_objects(ds)\n",
    "    time.sleep(.10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
