{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "This IPython Notebook contains simple examples of the rect function. \n",
    "\n",
    "To clear all previously rendered cell outputs, select from the menu:\n",
    "\n",
    "    Cell -> All Output -> Clear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from bokeh.plotting import figure, show, output_notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "N = 80"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "x = np.linspace(0, 4*np.pi, N)\n",
    "y = np.sin(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# fixed width and height\n",
    "p1 = figure(title=\"width/height screen units\")\n",
    "p1.rect(x, y, 6, 4, color=\"tomato\", width_units=\"screen\", height_units=\"screen\")\n",
    "show(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# variable width and height\n",
    "w = 0.02*np.exp(1+0.1*x)\n",
    "h = 0.2*abs(np.cos(x))\n",
    "p2 = figure(title=\"variable width/height\")\n",
    "p2.rect(x, y, w, h, color=\"olivedrab\", alpha=0.6)\n",
    "show(p2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# angle\n",
    "a = -np.pi/6\n",
    "p3 = figure(title=\"angle\")\n",
    "p3.rect(x, y, 0.1, 0.1, alpha=0.5, color=\"navy\", angle=a)\n",
    "show(p3)"
   ]
  },
  {
   "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
}
