{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "This IPython Notebook contains simple examples of many of the basic vectorizable glyph functions that Bokeh provides. \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 = 9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "x = np.linspace(-2, 2, N)\n",
    "y = x**2\n",
    "sizes = np.linspace(10, 20, N)\n",
    "xpts = np.array([-.09, -.12, .0, .12, .09])\n",
    "ypts = np.array([-.1, .02, .1, .02, -.1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"annular_wedge\")\n",
    "p.annular_wedge(x, y, 10, 20, 0.6, 4.1, color=\"#8888ee\",\n",
    "    inner_radius_units=\"screen\", outer_radius_units=\"screen\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"annular_wedge\")\n",
    "p.annulus(x, y, 10, 20, color=\"#7FC97F\",\n",
    "    inner_radius_units=\"screen\", outer_radius_units = \"screen\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"arc\")\n",
    "p.arc(x, y, 20, 0.6, 4.1,\n",
    "    radius_units=\"screen\", color=\"#BEAED4\", line_width=3)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"bezier\")\n",
    "p.bezier(x, y, x+0.2, y, x+0.1, y+0.1, x-0.1, y-0.1,\n",
    "    color=\"#D95F02\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"circle\")\n",
    "p.circle(x, y, radius=0.1, color=\"#3288BD\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"line\")\n",
    "p.line(x, y, color=\"#F46D43\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"multi_line\")\n",
    "p.multi_line([xpts+xx for xx in x], [ypts+yy for yy in y],\n",
    "    color=\"#8073AC\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"oval\")\n",
    "p.oval(x, y, 15, 25, angle=-0.7, color=\"#1D91C0\",\n",
    "    width_units=\"screen\", height_units=\"screen\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"patch\")\n",
    "p.patch(x, y, color=\"#A6CEE3\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"patches\")\n",
    "p.patches([xpts+xx for xx in x], [ypts+yy for yy in y], color=\"#FB9A99\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"quad\")\n",
    "p.quad(x, x-0.1, y, y-0.1, color=\"#B3DE69\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"quadratic\")\n",
    "p.quadratic(x, y, x+0.2, y, x+0.1, y+0.1, color=\"#4DAF4A\", line_width=3)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"ray\")\n",
    "p.ray(x, y, 45, -0.7, color=\"#FB8072\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"rect\")\n",
    "p.rect(x, y, 10, 20, color=\"#CAB2D6\",\n",
    "    width_units=\"screen\", height_units=\"screen\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"segment\")\n",
    "p.segment(x, y, x-0.1, y-0.1, color=\"#F4A582\", line_width=3)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"square\")\n",
    "p.square(x, y, size=sizes, color=\"#74ADD1\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"wedge\")\n",
    "p.wedge(x, y, 15, 0.6, 4.1, radius_units=\"screen\", color=\"#B3DE69\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"circle_x\")\n",
    "p.scatter(x, y, marker=\"circle_x\", size=sizes, color=\"#DD1C77\", fill_color=None)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"triangle\")\n",
    "p.scatter(x, y, marker=\"triangle\", size=sizes, color=\"#99D594\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"circle\")\n",
    "p.scatter(x, y, marker=\"o\", size=sizes, color=\"#80B1D3\", line_width=3)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"cross\")\n",
    "p.scatter(x, y, marker=\"cross\", size=sizes, color=\"#E6550D\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"diamond\")\n",
    "p.scatter(x, y, marker=\"diamond\", size=sizes, color=\"#1C9099\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"inverted_triangle\")\n",
    "p.scatter(x, y, marker=\"inverted_triangle\", size=sizes, color=\"#DE2D26\")\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"square_x\")\n",
    "p.scatter(x, y, marker=\"square_x\", size=sizes, color=\"#FDAE6B\",\n",
    "    fill_color=None, line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"asterisk\")\n",
    "p.scatter(x, y, marker=\"asterisk\", size=sizes, color=\"#F0027F\", line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"square_cross\")\n",
    "p.scatter(x, y, marker=\"square_cross\", size=sizes, color=\"#7FC97F\",\n",
    "    fill_color=None, line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"diamond_cross\")\n",
    "p.scatter(x, y, marker=\"diamond_cross\", size=sizes, color=\"#386CB0\",\n",
    "    fill_color=None, line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = figure(title=\"circle_cross\")\n",
    "p.scatter(x, y, marker=\"circle_cross\", size=sizes, color=\"#FB8072\",\n",
    "    fill_color=None, line_width=2)\n",
    "show(p)"
   ]
  }
 ],
 "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
}
