{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from bokeh.plotting import figure, gridplot, show, output_notebook\n",
    "from bokeh.models import ColumnDataSource"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "N = 300\n",
    "x = np.linspace(0, 4*np.pi, N)\n",
    "y1 = np.sin(x)\n",
    "y2 = np.cos(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "source = ColumnDataSource()\n",
    "source.add(data=x, name='x')\n",
    "source.add(data=y1, name='y1')\n",
    "source.add(data=y2, name='y2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "TOOLS = \"pan,wheel_zoom,box_zoom,reset,save,box_select,lasso_select\"\n",
    "\n",
    "s1 = figure(tools=TOOLS, plot_width=350, plot_height=350)\n",
    "s1.scatter('x', 'y1', source=source)\n",
    "\n",
    "# Linked brushing in Bokeh is expressed by sharing data sources between\n",
    "# renderers. Note below that s2.scatter is called with the `source` \n",
    "# keyword argument, and supplied with the same data source from s1.scatter\n",
    "s2 = figure(tools=TOOLS, plot_width=350, plot_height=350)\n",
    "s2.scatter('x', 'y2', source=source)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = gridplot([[s1,s2]])\n",
    "show(p)"
   ]
  },
  {
   "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
}
