{
 "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)\n",
    "y3 = np.sin(x) + np.cos(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "s1 = figure(plot_width=350, plot_height=350)\n",
    "s1.scatter(x, y1)\n",
    "\n",
    "# Linked panning in Bokeh is expressed by sharing ranges between\n",
    "# plots. Note below that s2 is reated with the `x_range` and `y_range` \n",
    "# keyword arguments, and supplied with the same ranges from s1. Here, \n",
    "# this links both axes together.\n",
    "s2 = figure(plot_width=350, plot_height=350, \n",
    "            x_range=s1.x_range, y_range=s1.y_range)\n",
    "s2.scatter(x, y2)\n",
    "\n",
    "# It is possible to share just one range or the other, to link plots\n",
    "# along only one dimension. For the third plot, we only link the x-axis\n",
    "s3 = figure(plot_width=350, plot_height=350, x_range=s1.x_range)\n",
    "s3.scatter(x, y3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p = gridplot([[s1,s2, s3]])\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
}
