{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Some examples of ggplot-based plots rendered by Bokeh"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from ggplot import aes, diamonds, geom_density, geom_line, geom_step, ggplot, meat\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from bokeh import mpl\n",
    "from bokeh.plotting import output_notebook, show"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "g = ggplot(diamonds, aes(x='price', color='cut')) + geom_density()\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Density ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "g = ggplot(aes(x='date', y='beef'), data=meat) + geom_line()\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Line ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.DataFrame({\n",
    "    \"x\": range(100),\n",
    "    \"y\": np.random.choice([-1, 1], 100)\n",
    "})\n",
    "df.y = df.y.cumsum()\n",
    "\n",
    "g = ggplot(aes(x='x', y='y'), data=df) + geom_step()\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Step ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
