{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import matplotlib.cbook as cbook\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from dautil import options\n",
    "import matplotlib as mpl\n",
    "from dautil import plotting\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "data = cbook.get_sample_data('aapl.csv', asfileobj=True)\n",
    "df = pd.read_csv(data, parse_dates=True, index_col=0)\n",
    "df = df.resample('M')\n",
    "close = df['Close'].values\n",
    "dates = df.index.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def plot(title, ax):\n",
    "    ax.set_title(title)\n",
    "    ax.set_xlabel('Date')\n",
    "\n",
    "    plotter = plotting.CyclePlotter(ax)\n",
    "    plotter.plot(dates, close, label='Close')\n",
    "    plotter.plot(dates, 0.75 * close, label='0.75 * Close')\n",
    "    plotter.plot(dates, 1.25 * close, label='1.25 * Close')\n",
    "\n",
    "    ax.set_ylabel('Price ($)')\n",
    "    ax.legend(loc='best')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, axes = plt.subplots(4, figsize=(30, 10))\n",
    "plt.tight_layout()\n",
    "plot('Initial', axes[0])\n",
    "sns.reset_orig()\n",
    "options.set_mpl_options()\n",
    "\n",
    "plot('After setting options', axes[1])\n",
    "\n",
    "sns.reset_defaults()\n",
    "plot('After resetting options', axes[2])\n",
    "\n",
    "with plt.style.context(('dark_background')):\n",
    "    plot('With dark_background stylesheet', axes[3])\n",
    "\n",
    "fig.autofmt_xdate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "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
}
