{
 "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 *\n",
    "from bokeh import mpl\n",
    "from bokeh.plotting import show\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "g = ggplot(diamonds, aes(x='price', color='cut')) + \\\n",
    "    geom_density()\n",
    "\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Density ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh(notebook=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "g = ggplot(aes(x='date', y='beef'), data=meat) + \\\n",
    "    geom_line()\n",
    "\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Line ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh(notebook=True))"
   ]
  },
  {
   "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",
    "\n",
    "df.y = df.y.cumsum()\n",
    "\n",
    "g = ggplot(aes(x='x', y='y'), data=df) + \\\n",
    "    geom_step()\n",
    "g.draw()\n",
    "\n",
    "plt.title(\"Step ggplot-based plot in Bokeh.\")\n",
    "\n",
    "show(mpl.to_bokeh(notebook=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 0
}