{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import dautil as dl\n",
    "import seaborn as sns\n",
    "import statsmodels.api as sm\n",
    "from IPython.display import HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = sm.datasets.get_rdataset(\"Duncan\", \"car\", cache=True).data\n",
    "transformed = df.copy()\n",
    "transformed['income'] = np.power(transformed['income'], 1.0/3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "context = dl.nb.Context('transforming_up')\n",
    "dl.nb.RcWidget(context)\n",
    "dl.nb.LabelWidget(2, 2, context)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "sp = dl.plotting.Subplotter(2, 2, context)\n",
    "sp.label()\n",
    "sns.regplot(x='income', y='prestige', data=df, order=3, ax=sp.ax)\n",
    "\n",
    "sp.label(advance=True)\n",
    "sns.regplot(x='income', y='prestige', data=transformed, ax=sp.ax)\n",
    "\n",
    "sp.label(advance=True)\n",
    "sns.residplot(x='income', y='prestige', data=df, order=3, ax=sp.ax)\n",
    "\n",
    "sp.label(advance=True)\n",
    "sp.ax.set_xlim([1, 5])\n",
    "sns.residplot(x='income', y='prestige', data=transformed, ax=sp.ax)\n",
    "plt.tight_layout()\n",
    "HTML(dl.report.HTMLBuilder().watermark())"
   ]
  },
  {
   "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
}
