mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
1795 lines
1.0 MiB
Python
1795 lines
1.0 MiB
Python
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"<!--BOOK_INFORMATION-->\n",
|
||
|
"<img align=\"left\" style=\"padding-right:10px;\" src=\"figures/PDSH-cover-small.png\">\n",
|
||
|
"*This notebook contains an excerpt from the [Python Data Science Handbook](http://shop.oreilly.com/product/0636920034919.do) by Jake VanderPlas; the content is available [on GitHub](https://github.com/jakevdp/PythonDataScienceHandbook).*\n",
|
||
|
"\n",
|
||
|
"*The text is released under the [CC-BY-NC-ND license](https://creativecommons.org/licenses/by-nc-nd/3.0/us/legalcode), and code is released under the [MIT license](https://opensource.org/licenses/MIT). If you find this content useful, please consider supporting the work by [buying the book](http://shop.oreilly.com/product/0636920034919.do)!*\n",
|
||
|
"\n",
|
||
|
"*No changes were made to the contents of this notebook from the original.*"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"<!--NAVIGATION-->\n",
|
||
|
"< [Geographic Data with Basemap](04.13-Geographic-Data-With-Basemap.ipynb) | [Contents](Index.ipynb) | [Further Resources](04.15-Further-Resources.ipynb) >"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Visualization with Seaborn"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Matplotlib has proven to be an incredibly useful and popular visualization tool, but even avid users will admit it often leaves much to be desired.\n",
|
||
|
"There are several valid complaints about Matplotlib that often come up:\n",
|
||
|
"\n",
|
||
|
"- Prior to version 2.0, Matplotlib's defaults are not exactly the best choices. It was based off of MATLAB circa 1999, and this often shows.\n",
|
||
|
"- Matplotlib's API is relatively low level. Doing sophisticated statistical visualization is possible, but often requires a *lot* of boilerplate code.\n",
|
||
|
"- Matplotlib predated Pandas by more than a decade, and thus is not designed for use with Pandas ``DataFrame``s. In order to visualize data from a Pandas ``DataFrame``, you must extract each ``Series`` and often concatenate them together into the right format. It would be nicer to have a plotting library that can intelligently use the ``DataFrame`` labels in a plot.\n",
|
||
|
"\n",
|
||
|
"An answer to these problems is [Seaborn](http://seaborn.pydata.org/). Seaborn provides an API on top of Matplotlib that offers sane choices for plot style and color defaults, defines simple high-level functions for common statistical plot types, and integrates with the functionality provided by Pandas ``DataFrame``s.\n",
|
||
|
"\n",
|
||
|
"To be fair, the Matplotlib team is addressing this: it has recently added the ``plt.style`` tools discussed in [Customizing Matplotlib: Configurations and Style Sheets](04.11-Settings-and-Stylesheets.ipynb), and is starting to handle Pandas data more seamlessly.\n",
|
||
|
"The 2.0 release of the library will include a new default stylesheet that will improve on the current status quo.\n",
|
||
|
"But for all the reasons just discussed, Seaborn remains an extremely useful addon."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Seaborn Versus Matplotlib\n",
|
||
|
"\n",
|
||
|
"Here is an example of a simple random-walk plot in Matplotlib, using its classic plot formatting and colors.\n",
|
||
|
"We start with the typical imports:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"plt.style.use('classic')\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"import numpy as np\n",
|
||
|
"import pandas as pd"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Now we create some random walk data:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Create some data\n",
|
||
|
"rng = np.random.RandomState(0)\n",
|
||
|
"x = np.linspace(0, 10, 500)\n",
|
||
|
"y = np.cumsum(rng.randn(500, 6), 0)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"And do a simple plot:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd4VFX6xz93Jsn09N5JQofQQSyIiqggAqtrL6irrsta\nVlnF/bnY1oKuupZ1ddcCWFlXFBEVRQ1F6TVACCG99+ktM3N/f9wQEpJAykCC3M/z8DC55dwzd2a+\n59z3vEUQRREZGRkZmV8/ir7ugIyMjIzMqUEWfBkZGZkzBFnwZWRkZM4QZMGXkZGROUOQBV9GRkbm\nDEEWfBkZGZkzBL8JviAICkEQdgqC8GXz32GCIHwnCEKuIAhrBEEI8de1ZGRkZGS6jz9n+PcBB1r9\nvRBYK4riYOBH4BE/XktGRkZGppv4RfAFQUgEZgBvt9o8G1ja/HopMMcf15KRkZGR6Rn+muG/DPwZ\naB22GyOKYjWAKIpVQLSfriUjIyMj0wN6LfiCIMwEqkVR3A0IxzlUzuEgIyMj04cE+KGNc4ArBEGY\nAWgAgyAI7wNVgiDEiKJYLQhCLFDT0cmCIMgDgYyMjEwPEEXxeJPsdvR6hi+K4l9EUUwWRTENuBb4\nURTFm4BVwLzmw24BVh6n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TmEB8rGcz1Dlz5hAQEIDVaiU6Opo1a9b4pT/d\nJUvI8ks7U8WpPTrvyH04YsN/4YUXuP322/3SJxkZf7Kiro7f+GFm3xpBEFoqUPWnBdqOOK0Fv6dC\n7S9WrlzJBRdcgCiKfPHFF0yZMoWcnByio09tnrieCrW/OHIfZGT6C7cePMhdcXGcFRLSss3p9fJN\nfT3/6CBvzpmCbMPvBUd
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x1023b2cc0>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Plot the data with Matplotlib defaults\n",
|
||
|
"plt.plot(x, y)\n",
|
||
|
"plt.legend('ABCDEF', ncol=2, loc='upper left');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Although the result contains all the information we'd like it to convey, it does so in a way that is not all that aesthetically pleasing, and even looks a bit old-fashioned in the context of 21st-century data visualization.\n",
|
||
|
"\n",
|
||
|
"Now let's take a look at how it works with Seaborn.\n",
|
||
|
"As we will see, Seaborn has many of its own high-level plotting routines, but it can also overwrite Matplotlib's default parameters and in turn get even simple Matplotlib scripts to produce vastly superior output.\n",
|
||
|
"We can set the style by calling Seaborn's ``set()`` method.\n",
|
||
|
"By convention, Seaborn is imported as ``sns``:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import seaborn as sns\n",
|
||
|
"sns.set()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Now let's rerun the same two lines as before:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAe8AAAFXCAYAAACLEMbVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXl8XOV56P89s+8aSTPaJUuWvOINMDY2a+ywBhJMSiAl\nISlJadK0SdOmuWna29/t7W3uvWnTS9PcXKAJJRDSAGULS2Iwiw0YG2O8r7L2dSTNvq/n98fRjDTW\nLo0sG7/fz4cPM+e855znHI3P8z7P+yySLMsyAoFAIBAILhhUCy2AQCAQCASCmSGUt0AgEAgEFxhC\neQsEAoFAcIEhlLdAIBAIBBcYQnkLBAKBQHCBIZS3QCAQCAQXGAVT3plMhm3btvG1r30NAL/fz/33\n389NN93EV77yFYLBYKEuJRAIBALBRU3BlPfjjz9OY2Nj7vsjjzzCpk2b2L59Oxs3buThhx8u1KUE\nAoFAILioKYjy7u/vZ+fOndx11125bW+88Qbbtm0DYNu2bezYsaMQlxIIBAKB4KKnIMr7Bz/4Ad/9\n7neRJCm3ze1243A4AHA6nXg8nkJcSiAQCASCi545K++3334bh8PBihUrmKzS6mjFLhAIBAKBYPZo\n5nqCjz76iDfffJOdO3cSj8cJh8P85V/+JQ6Hg6GhIRwOB4ODg5SUlEx5LlmWhZIXCAQCgWAKpEI2\nJvnggw949NFHeeihh/jhD3+I3W7ngQce4JFHHiEQCPCd73xnynMMDoqo9PnG6bSK5zzPiGc8/4hn\nPP+IZ3xucDqtMz5m3vK8H3jgAXbv3s1NN93Enj17eOCBB+brUgKBQCAQXFQU1PIuBGKWN/+I2fT8\nI57x/COe8fwjnvG54byyvAUCgUAgEMwPQnkLBAKBQHCBIZS3QCAQCAQXGEJ5CwQCgUBwgSGUt0Ag\nEAgEFxhzLtJysbBr19v89V//JU8++Z/U1S1aaHEKxrXXbqCpaQnJZBKNRsNNN93K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s5N5772XNmjW43W4cDmVR3+l04vHMPqpuodm5c+9CizBvfJzvTSAQXDgE/LG870sv\nKR8zxmTRUVRspLvDSyqZRqNVF1QGvzc2Ztu1Ny3lsk2LsBYZctvKKq20nBxkoC+IzW4kFk2iN2gY\ndIWwFhmw2AxjznM21iIDSy8p5/Qx16xkLYjyVqlUvPDCC4RCIb7xjW/Q3Nw8xjL9uFiqAoFAICg8\n2YjuDdfUs3ZD7biKWZIkGpY6OLi3i652Lw1Lxo/6nqsMarVEOi1TXGpCkqQ8xQ3kAukG+oIYjFpe\n+vUh1m2sJRZJUrVsekuqkiSx5bblLF9TMStZCxptbrFY2LBhA++88w6lpaUMDQ3hcDgYHBykpKRk\nWueYTVNywcwRz3n+Ec94/hHPeP45V8+47dQQADWLSqismjgY+PIrF3FwbxfvvtZMw2JHzv2cRZZl\nDn7QRVWdnfJR0erTofmoYgXf+YXLcA+GaVjiGPf+i2xGXlIdwtXjxzBcsOXgXqUaXH3j+MdMRFnZ\nzGTMMmfl7fF40Gq1WK1WYrEYu3fv5oEHHmDLli0899xzPPDAAzz//PNs3bp1WucbHJzd4r1g+jid\nVvGc5xnxjOcf8Yznn3P5jHu7h4ufqCbXAzqjhvVX1/Phu+3sfvsMm7c25e3v6/Lx0tOHAKheZGfT\nJxrHKPipZJA0EsuGLeKJZKlpKKazxUM8np/qZbLqZvzMZjNBmrPyHhwc5Hvf+x6ZTIZMJsOtt97K\nddddx9q1a/mzP/sznn32Waqrq3nwwQfneimBQCAQfEwJeBWXtc0+9XrxJesq+fDddoKB/DVqV2+A\nV/9zpJBXT4ePQ/u6+OT
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11a0d73c8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# same plotting code as above!\n",
|
||
|
"plt.plot(x, y)\n",
|
||
|
"plt.legend('ABCDEF', ncol=2, loc='upper left');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Ah, much better!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Exploring Seaborn Plots\n",
|
||
|
"\n",
|
||
|
"The main idea of Seaborn is that it provides high-level commands to create a variety of plot types useful for statistical data exploration, and even some statistical model fitting.\n",
|
||
|
"\n",
|
||
|
"Let's take a look at a few of the datasets and plot types available in Seaborn. Note that all of the following *could* be done using raw Matplotlib commands (this is, in fact, what Seaborn does under the hood) but the Seaborn API is much more convenient."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Histograms, KDE, and densities\n",
|
||
|
"\n",
|
||
|
"Often in statistical data visualization, all you want is to plot histograms and joint distributions of variables.\n",
|
||
|
"We have seen that this is relatively straightforward in Matplotlib:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfAAAAFXCAYAAABdtRywAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3W9wVOX99/HP/g3JJiGEZJeUG+nPdKw6Rn3ATOe2TrT8\nMdgIYrMtdKbTDrG17Qyi1o4dEVAHihUt9Ul1pCqMjJJBirWYsfU21qRqsdVW4a5D/4j9RZKyISYh\nm+wm2d1z7gf+2NsUkt1NNuxey/v1KLt7Xdf5fnHXz56zu+c4bNu2BQAAjOLMdQEAACBzBDgAAAYi\nwAEAMBABDgCAgQhwAAAMRIADAGCgtAK8o6NDy5cvV0NDg3bu3HnG421tbVq5cqVWrVqlYD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PJ4i+T1zsp4jsvjPmOex+OWwxmfdj0u\njzvjNxUA8g+fgQMAYCACHAAAAxHgAAAYiAAHAMBABDgAAAYiwAEAMBABDgCAgQhwAAAMRIADAGAg\nAhwAAAMR4AAAGIgABwDAQAQ4AAAGIsABADAQAQ4AgIEIcAAADESAAwBgoLQCvKOjQ8uXL1dDQ4N2\n7tx5xuPHjh3TmjVrVFdXp127do17bPHixVq5cqVWrVqlYDCYnaoBADjPuVMNsCxLW7Zs0e7du+X3\n+xUMBrVkyRLV1tYmx1RUVGjjxo165ZVXzpjvcDi0Z88ezZ49O7uVAwBwHku5B3748GEtXLhQ8+fP\nl8fjUWNjo9ra2saNqay
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11a191080>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data = np.random.multivariate_normal([0, 0], [[5, 2], [2, 2]], size=2000)\n",
|
||
|
"data = pd.DataFrame(data, columns=['x', 'y'])\n",
|
||
|
"\n",
|
||
|
"for col in 'xy':\n",
|
||
|
" plt.hist(data[col], normed=True, alpha=0.5)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Rather than a histogram, we can get a smooth estimate of the distribution using a kernel density estimation, which Seaborn does with ``sns.kdeplot``:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfAAAAFXCAYAAABdtRywAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Wl0XfV9N/rv3vvMs47OoNGSLM+2PIMZzWCI3RgIfewb\nnHY9K417n67Vu1hZffO86Qq0KbntvVktTZ8+pQmEGwoluIYQCDiOwQZsDLbxLE+Sbc3j0Tycedj7\nvjiWsLHkcySdWd/PmyKdPfz+qaWv9v5PgqIoCoiIiCiviNkugIiIiGaOAU5ERJSHGOBERER5iAFO\nRESUhxjgREREeYgBTkRElIeSCvAjR45g27Zt2Lp1K15++eXbPj906BCeeuopPP3009i5cydOnz6d\n9LlEREQ0c0KieeCyLGPr1q147bXX4HK5sHPnTrz44ouora2dPCYQCECv1wMAGhsb8Vd/9VfYv39/\nUucSERHRzCV8Aq+vr0dVVRXKy8uhVquxfft2HDp06JZjJsIbAPx+P0RRTPpcIiIimjlVogM8Hg9K\nS0snv3a73bhw4cJtxx08eBD/9E//hKGhoclX5cmeS0RERDOTskFsjz32GPbv349/+7d/w89+9rNU\nXZaIiIimkDDA3W43uru7J7/2eDxwuVzTHr9x40Z0dHRgZGRkxudO4PLsREREd5bwFXpdXR3a29vR\n1dUFp9OJffv24cUXX7zlmPb2dixYsAAAcOnSJUQiEdhstqTOnYogCOjvH59lk3KD02nO+zYAhdGO\nQmgDwHbkkkJoA1AY7SiENgDxdsxUwgCXJAnPPfccdu/eDUVRsHPnTtTW1mLPnj0QBAHPPPMMDhw4\ngPfffx9qtRparXbyFfp05xIREdHcJJxGli35/hdVIf1VmO/tKIQ2AGxHLimENgCF0Y5CaAMwuydw\nrsRGRESUhxjgREREeYgBTkRElIcY4ERERHmIAU5ERJSHGOBERER5iAFORESUhxjgREREKdDQcBnf\n//73EIlEEAgE8N//+3fR0tKctvslXImNiIgo3+z95DpONvSl9Jp3LXPhu48umvbzZctW4MEHH8LL\nL7+EUCiIrVu/jZqahSmt4WZ8AiciIkqRP/uz/xMnT55AY2MD/vRPv5/We/EJnIiICs53H110x6fl\ndBkZGUEg4EcsFkU4HIJWq0vbvfgETkRElCL/+I9/j//xP/4S3/rWH+Gll/5XWu/FACciIkqBP/xh\nH1QqNR57bCv+9E+/j4aGKzhz5lTa7sdX6ERER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2cPBEHAM888g5deegmjo6P48Y9/DEVRJqeLDQwM4Nlnn4UgCIjFYnjyySfxwAMPzKpxRPnk6kgT\nAKBEf/vbqkyQBAlrHKvwZc9X+LLrK2yp2pz4JCLKK4KiKEq2i5hKvv9FVUh/FeZ7O7LRhp/X/woX\nBq7gB8u/B4vOkpJrzuQJHIivwf7qxf+EWWXECw/8NUQhN9Zt4r+p3FEI7SiENgCzewLPjZ9oogIi\nKzKuj7TAprakLLxnQ6/SYbl9CUYiY7gwcDlrdRBRejDAiVKsy9uDQDSIEp0726VgrbMOAPBRy6dZ\nroSIUo0BTpRi14bj/d+lxuz0f9+sWF+EBeYKtHo70DnenfgEIsobDHCiFLs20gIAqCrK3AIud7LG\nuQoAcKjtcJYrIaJUYoATpVC8/7sZFrUZ1iz2f9+sxrIAVo0FZ/rr4Y1wq1GiQsEAJ0qhHp8H/mgA\nZTnQ/z1BEASsca5EVInhaOeJbJdDRCnCACdKobaxDgCAQ2fPciW3WlG8FGpRhcOdRxGTY9kuh4hS\ngAFOlEITAV5mLU1wZGZ
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11a195a90>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for col in 'xy':\n",
|
||
|
" sns.kdeplot(data[col], shade=True)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Histograms and KDE can be combined using ``distplot``:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfAAAAFmCAYAAACSk8i4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAAC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46le/\nyn333beizglRaebbNWzahfgVAAK6d52jKjJ0gy9s+hy/uPQb/jT0Ng90fr4scQgh1k5Jz8D37ds3\na2IawBNPPDHz72effZZnn312znmdnZ289NJLNxmiEJVrvl3DAKampgBosNWtd0gz7u24h19feYXf\n9/+RL266F12Tuk1C1BL5iRZilVlKMZIaw6U5cRrl26fba/dwd+tdjKXHORX5qGxxCCHWhiRwIVbZ\nZGaKnJWj3lb+4kX3dxYfWb3a/4cyRyKEWG2SwIVYZSPJUQDqjfIn8DZPkJ3127kweZmBWGjpE4QQ\nVUMSuBCrbCQVAaDe5i9zJEVf7LwXgKMDfyxzJEKI1bT6mxMLsYEppRhNRvDY3Tj1yli6tbtxJ02u\nRt4Ov8efb/vKnLKu0xZbFjfN5/OjadpahCmEWCZJ4EKsoqlslKyVo8PbtnTjdaJrOl/Y9Dn+4+Nf\n8nroLb7cff+87RZbFgeQSiZ5YNs+/P7yPxoQQsgtdCFW1VhqAoAm19zqa+X02ba9mIbJsYE/UbAK\nC7abXhY3b432BRK7EKI8JIELsYrG08UE3uCsL8vnT98Gj0anZn3lklnubOhlIjPJB6MfliU2IcTq\nklvoQqyisfQEuqYTcAQYJ7Lun7/YNqVurbjL2StXjnJn8Pb1Dk0IscokgQuxSgpWganMFPXOOowy\nVj2b3qb0kzx4CE41czU
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11acced30>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.distplot(data['x'])\n",
|
||
|
"sns.distplot(data['y']);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"If we pass the full two-dimensional dataset to ``kdeplot``, we will get a two-dimensional visualization of the data:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata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OG3h7\n+/Dhh5/j7u5hs534TLYeYrKWINzGrFYrmzat57vvvqasrAxvbx9mznyYIUOGiyHoFjJs2EgKCwv4\n4YcFvPTSc7zxxrsNhrEg/JkIYkG4hSQlHePLLz8hOfkMdnZ2zJjxIPfeOwU7O7uWvrRmZbFY0FXr\nMBqNGIw11BhrkKxWQgJDUKtuzvXMU6bMoKKigt9++5UXX3yWN998Dw8Pz5a+LOEWIIJYEG4B5eXl\nvPvu22zatB6AIUOG89BDj+Lt7X3DrsFkMmEym1CpVCgVymse/pYkCW2lltzCXHIL88jOyyE7P4vs\nvGxyCnJtlspUKpXERMTQsU1HunXoQvs27VHIb45RAJlMxmOPPYFCoWD58p+ZM+dZ3nzzXby8btw9\nEm5N4hlxKyaeR936LBYLa9b8xqJF31FZWUlUVDR//esztGvX4bqcz2gykpKRwqmU06RlpVFcVkJp\neSmlFaVU6aoutJPJZKiUKtRqNW4ubri5uuGmccNd44aToxN2ajtUKhVqlRqFXEGVrgqtTktlVSXa\nqkqKS4vILcxDX62vdw2ODo4E+Qfh5eaJndoOtVqNndoOi9XK6dTTpGakYpVqS3GGBobwjydeItg/\n+Lr8PK6GJEl89918fv55MT4+vsyd+zZBQbXXJz6TrYeYrCU0ifjQ39qOHj3C559/RHp6Gs7Ozkyf\n/gBjx05o1ufAFquFE8kn2Zewj6QzSaRmpmG21O2JOjs64e7mgYerO2qVGpPZdKF3bKipoVxbTqWu\nkiv5p0StUuPv44e/TwABPv74+/gT6BdISEAw7q7ujfa29dV6ks4ksW3fdrbu24aDvQPPPvwM/Xv2\nv+qfQ3OTJImfflrE999
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11aebdbe0>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.kdeplot(data);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We can see the joint distribution and the marginal distributions together using ``sns.jointplot``.\n",
|
||
|
"For this plot, we'll set the style to a white background:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGmCAYAAAAzhPA+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VNXdBvBn1uz7ThICSQhr2ARERERQQIEiotZSq4LW\n2lfRYiutWnfFFpdaa1VUtCKuqIiKCxgFBGWVnQBJIPu+78ks9/0jEoFss9yZc+/M8/18+LySzNz7\nm7z0Pvmdc+65GkmSJBAREQmmFV0AERERwEAiIiKFYCAREZEiMJCIiEgRGEhERKQIDCQiIlIEvegC\niORW29CGPZll2HusDAeyKtDQbOr2dVqtBonRgUhPicTEEXEYnhIBvY6/oxGJouF9SOQJTGYrdh8t\nRcbuAuw5VgarteOfdViQEbHhvggNMiLYzwirBJgtVtQ3t6O8phVl1a1oN1sBAIF+Bkwdm4BZFwxA\nUlywyI9D5JUYSKRqxRWN+HpHHjL25KOusR0AEB/ph6FJIRgyIApxUUHQaDQ9vt9iseJUST0OZZcj\nM7cGjS1mAMDQAeFYcEkqxg+LhVbb8/uJSD4MJFKd1jYzth8sxqZd+ThysgoAEOCrR3pyCEYPjkH/\n2DCHjmuxWHEsrwY7DhUhp7gBAJAYE4RrL03DlNHxDCYiF2MgkSpIkoQT+TXYtCsfW/cVoqXNAgBI\n6ReIkanhGD24Hwx6nWznK6tuxua9eTiUUw2rBKQkhGDR7OEYlRYl2zmI6GwMJFI0s8WKbQeKsW5z\nNk4W1QEAQgMNGJkShrFD4hAdHujS81fXt2LjjlM4mFMNALhwVD/cNn8kQoN8XHpeIm/EQCJFslol\nfLunAO9sP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ure at 0x11ad139b0>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" sns.jointplot(\"x\", \"y\", data, kind='kde');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"There are other parameters that can be passed to ``jointplot``—for example, we can use a hexagonally based histogram instead:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGmCAYAAAAzhPA+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXmUZVV99/3dZ7znjjVX9UxDN/MkECK0ooLoE4wMComI\nmrzGpb4GeZdmSQIreaJLAYNTEk00UXyeV9Fo9NX4EBONUYQIIhEEEbqhR7qrqmu+8z3j3vv949x7\nq27dsenqvreqfp+1VKw6tc+uU5f9Pfuc3/f3ZVJKCYIgCILoMkq3J0AQBEEQAAkSQRAE0SOQIBEE\nQRA9AQkSQRAE0ROQIBEEQRA9AQkSQRAE0RNo3Z4AQawEUkrkcrm2xyWTSTDGTsKMCII4VkiQiDVB\nLpfD//npc4hGY02PKZWKuPbVZyOVSp3EmREE0SkkSMSaIRqNIRZPdnsaBEG8ROgdEkEQBNET0A6J\nWDdIKZHNZtseR++ZCKI7kCAR64ZSqYAf/nwBAwODLY6h90wE0S1IkIiep5MKumw2C4n2fYIt6/jf\nM1FFH0GcGEiQiJ6nkwq6udlpxOIpxOO9MR/aaRHEsUOCRKwK2lXQFYv5kzgbqugjiBMBCRLRVVby\ncdxKzadd4cPJnA9BrCdIkIiu0muP4zopfDiZ8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pjvfa1\nrwMXEkUnwAUXXIi7774H1177xuqO44knnqgubIODg7j00kvxzDPPIBaL4fzzz6+e48wzz8TExERV\nkK655ho4XoCFnAshFhe
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11543ac18>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" sns.jointplot(\"x\", \"y\", data, kind='hex')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Pair plots\n",
|
||
|
"\n",
|
||
|
"When you generalize joint plots to datasets of larger dimensions, you end up with *pair plots*. This is very useful for exploring correlations between multidimensional data, when you'd like to plot all pairs of values against each other.\n",
|
||
|
"\n",
|
||
|
"We'll demo this with the well-known Iris dataset, which lists measurements of petals and sepals of three iris species:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>sepal_length</th>\n",
|
||
|
" <th>sepal_width</th>\n",
|
||
|
" <th>petal_length</th>\n",
|
||
|
" <th>petal_width</th>\n",
|
||
|
" <th>species</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>5.1</td>\n",
|
||
|
" <td>3.5</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>4.9</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>4.7</td>\n",
|
||
|
" <td>3.2</td>\n",
|
||
|
" <td>1.3</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>4.6</td>\n",
|
||
|
" <td>3.1</td>\n",
|
||
|
" <td>1.5</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>5.0</td>\n",
|
||
|
" <td>3.6</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" sepal_length sepal_width petal_length petal_width species\n",
|
||
|
"0 5.1 3.5 1.4 0.2 setosa\n",
|
||
|
"1 4.9 3.0 1.4 0.2 setosa\n",
|
||
|
"2 4.7 3.2 1.3 0.2 setosa\n",
|
||
|
"3 4.6 3.1 1.5 0.2 setosa\n",
|
||
|
"4 5.0 3.6 1.4 0.2 setosa"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"iris = sns.load_dataset(\"iris\")\n",
|
||
|
"iris.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Visualizing the multidimensional relationships among the samples is as easy as calling ``sns.pairplot``:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAyQAAALGCAYAAAC08VU5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xt0W9WdN/yvLpYlW5Id25Ls2JKdOBc7JnEDTgLk4kBq\n0gHSpKUkmXGAEijtGwIdAg2ri04YOkCYPgwU2ud5eFteyqWZhJS2MAy0YQjEgYQQ0oYEcuGaRL7J\njmM7lu+2pPcPR7LOkWRJ1pGO5Hw/a7FWjs45W1tH+2yxfX77txUej8cDIiIiIiIiGSjlrgARERER\nEV28OCAhIiIiIiLZcEBCRERERESy4YCEiIiIiIhkwwEJERERERHJhgMSIiIiIiKSjVruCjz//PN4\n5ZVXoFAoMGPGDGzduhUajca3/+DBg9iwYQOsVisAoKamBhs2bJCrukREREREJCFZByQtLS146aWX\n8Je//AUajQb//M//jDfffBOrVq0SHFdVVYVnnnlGploSEREREVG8yP6ExO12o6+vD0qlEv39/TCb\nzXJXiYiIiIiIEkTWOSQWiwW33norli5diiVLlsBgMODKK68MOO7w4cNYuXIl7rjjDnz55Zcy1JSI\niIiIiOJB1gFJV1cXdu/ejXfffRfvvfceent78frrrwuOqaiowJ49e/Daa6+htrYWd955Z0Rlezye\neFSZSHJsq5Qq2FYplbC9EqUOWUO29u/fD6vViuzsbAAjE9YPHz6MFStW+I7JzMz0/bu6uhoPPfQQ\nOjs7feeEolAocPasc1z1MpkM4z431c9P5bpLdX6ixdJWg4n1GiSizIutvHiUmcptVaprkUzlJFNd\npCpHyrrIIdn71mQvLx5lJnt53jIp8WR9Qj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
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.pairplot(iris, hue='species', size=2.5);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Faceted histograms\n",
|
||
|
"\n",
|
||
|
"Sometimes the best way to view data is via histograms of subsets. Seaborn's ``FacetGrid`` makes this extremely simple.\n",
|
||
|
"We'll take a look at some data that shows the amount that restaurant staff receive in tips based on various indicator data:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>total_bill</th>\n",
|
||
|
" <th>tip</th>\n",
|
||
|
" <th>sex</th>\n",
|
||
|
" <th>smoker</th>\n",
|
||
|
" <th>day</th>\n",
|
||
|
" <th>time</th>\n",
|
||
|
" <th>size</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>16.99</td>\n",
|
||
|
" <td>1.01</td>\n",
|
||
|
" <td>Female</td>\n",
|
||
|
" <td>No</td>\n",
|
||
|
" <td>Sun</td>\n",
|
||
|
" <td>Dinner</td>\n",
|
||
|
" <td>2</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>10.34</td>\n",
|
||
|
" <td>1.66</td>\n",
|
||
|
" <td>Male</td>\n",
|
||
|
" <td>No</td>\n",
|
||
|
" <td>Sun</td>\n",
|
||
|
" <td>Dinner</td>\n",
|
||
|
" <td>3</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>21.01</td>\n",
|
||
|
" <td>3.50</td>\n",
|
||
|
" <td>Male</td>\n",
|
||
|
" <td>No</td>\n",
|
||
|
" <td>Sun</td>\n",
|
||
|
" <td>Dinner</td>\n",
|
||
|
" <td>3</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>23.68</td>\n",
|
||
|
" <td>3.31</td>\n",
|
||
|
" <td>Male</td>\n",
|
||
|
" <td>No</td>\n",
|
||
|
" <td>Sun</td>\n",
|
||
|
" <td>Dinner</td>\n",
|
||
|
" <td>2</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>24.59</td>\n",
|
||
|
" <td>3.61</td>\n",
|
||
|
" <td>Female</td>\n",
|
||
|
" <td>No</td>\n",
|
||
|
" <td>Sun</td>\n",
|
||
|
" <td>Dinner</td>\n",
|
||
|
" <td>4</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" total_bill tip sex smoker day time size\n",
|
||
|
"0 16.99 1.01 Female No Sun Dinner 2\n",
|
||
|
"1 10.34 1.66 Male No Sun Dinner 3\n",
|
||
|
"2 21.01 3.50 Male No Sun Dinner 3\n",
|
||
|
"3 23.68 3.31 Male No Sun Dinner 2\n",
|
||
|
"4 24.59 3.61 Female No Sun Dinner 4"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tips = sns.load_dataset('tips')\n",
|
||
|
"tips.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGnCAYAAAAJ03gWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X1UVPW+P/D3zKg3nkRmGMywk4pi3lN4T6KkGBpYrCyT\nB6V8QA92w/qJGvkQonnWMcJOHpWunHuFe+u6FOvEMpGDViqoodcDlN2TdkMtTYkxYWCQeBSZ2b8/\nXJAgsIdh73EP836t1YoZ5vuZD9v5rjd77y97qwRBEEBERKRg6nvdABERkRiGFRERKR7DioiIFI9h\nRUREisewIiIixWNYERGR4jGsZFBfX49ly5YBACorK7F06dJ70kdoaCiuXbsmS22DwYDQ0FBZalP/\npZS5ERsbi6effhqRkZGYNWsWoqOj8cUXX7R/f+nSpTAajfekN+ragHvdQH9048YNnD9/HgDg4+OD\njIyMe9KHSqVy6PrU/yhlbgBAamoqAgMDAQDffvstXnrpJXz44Yfw8/O7p31R1xhWMnj77bdRWVmJ\n5cuXIykpCbGxsTh27BjWrVsHFxcXnDlzBnV1dUhOTkZubi4uXLiAsLAwvPHGG7BYLHj33XdRUlIC\ni8WCyMhILF68uEP9/Px8pKendwiLkSNHYtu2bR1e193fe4eGhiIrKwsPPPAASkpKsGPHDuzZswex\nsbEICAjAmTNnUFNTgw0bNuCJJ57AtWvXsG7dOphMJri4uCAlJQVubm5obm7GqlWrcPHiRXh6euIv\nf/kLPD09pd+g1G8oZW4AHefHI488gpkzZ2Lfvn1444032udIcXExTp48idraWvz000+YOnUqNm7c\niJKSEmRkZOC+++7DpUuXMHbsWGzduhUDBgzAgQMHsHv3bgiCgN/+9rfYuHEjBg0ahMcffxyPPPII\nqqursW/fPmg0Gvk2dH8kkOTKy8uF0NDQu75OSkoSEhISBEEQhJycHCEwMFAwmUxCfX298Nhjjwl1\ndXXCRx99JLzzzjuCIAjCzZs3h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qMRWq3WqhpGY51NjfZEr/eQpa6c\ntR2trpy1Ha1uW225OOK2kKK2NcvUuxvXm/d3hG3h6HXbaktJ9DCgyWRCXd3tH6a5uRmnT5+Gn58f\nQkNDsX//fgBATk4OwsLCJG2MiIiojeieldFoRFJSEiwWCywWC2bOnIlp06Zh/PjxeO211/DJJ5/A\n19cXaWlp9uiXiIickGhYjR07Fjk5OXc9P2TIEOzatUuOnoiIiDrgtQGJiEjxGFZERKR4DCsiIlI8\nhhURESkew4qIiBSPYUVERIrHsCIiIsVjWBERkeIxrIiISPEYVkREpHgMKyIiUjyGFRERKR7DioiI\nFI9hRUREisewIiIixRO9n9X169exdu1aVFdXQ61WIyYmBrGxsUhPT0d2djZ0Oh0AIDExESEhIbI3\nTEREzkc0rDQaDdatW4dx48ahoaEBUVFRmDJlCgAgLi4OcXFxsjdJRETOTTSs9Ho99Ho9AMDNzQ1+\nfn6orKwEAAiCIG93RERE6OU5q/Lycpw/fx4BAQEAgKysLMyePRvr169HXV2dLA0SERFZHVYNDQ1Y\nsWIFkpOT4ebmhvnz56OgoAC5ubnw9vbG5s2b5eyTiIicmEqw4lhea2srli5dipCQECxevPiu7xsM\nBrzyyivIy8uTpUki6v8uXryIpe/kw93L1+ox9TUGZCTNgL+/v4ydkRKInrMCgOTkZIwePbpDUBmN\nxvZzWUePHrX6w2I0Sn+4UK/3kKWunLUdra6ctR2tblttuTjitpCitslUb/O43ry/I2wLR6/bVltK\nomF15swZ5OXlwd/fHxE
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11c3a3fd0>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tips['tip_pct'] = 100 * tips['tip'] / tips['total_bill']\n",
|
||
|
"\n",
|
||
|
"grid = sns.FacetGrid(tips, row=\"sex\", col=\"time\", margin_titles=True)\n",
|
||
|
"grid.map(plt.hist, \"tip_pct\", bins=np.linspace(0, 40, 15));"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Factor plots\n",
|
||
|
"\n",
|
||
|
"Factor plots can be useful for this kind of visualization as well. This allows you to view the distribution of a parameter within bins defined by any other parameter:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVgAAAEWCAYAAAAjPo9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtUlHX+B/D3AKIoJJdBLNAyFC9JeVIhwlUXTCyzddBq\nwyyDoIviwmrmZSkva55MWxTcFNNcNXYLZdjEylZadbVM3c4GlHmL1WYS5WIEyG2Y+f3Bb2ZFLjOD\n851n5uH9OodzhuHhmc+jzJsv3+d7URgMBgOIiMjmXKQugIhIrhiwRESCMGCJiARhwBIRCcKAJSIS\nhAFLRCSI8ICtrq7G/Pnz8fDDD2Pq1Kn45ptvUFVVhfj4eMTExCAhIQHV1dWiyyAisjuF6HGwixcv\nxtixYzFjxgzodDrU1dVh8+bN8Pb2RmJiIrKysvDLL79g4cKFIssgIrI7oS3YmpoanDp1CjNmzAAA\nuLm5wcvLCwUFBVCpVAAAlUqFgwcPiiyDiEgSQgNWo9HAx8cHS5YsgUqlQlpaGurq6lBRUQGlUgkA\n8Pf3R2VlZZfOr9PpoNFooNPpbFk2EZFNCA1YnU6H7777DnFxcVCr1fDw8EBWVhYUCkWr427+vD0Z\nGRkYOnRoq4977rkH0dHRKC0tFXUJRERdJjRg+/fvj/79+yM0NBQAMHnyZHz33Xfw8/NDeXk5AKCs\nrAy+vr5mz5WcnIwzZ860+igoKBBZPhHRLREasEqlErfffjtKSkoAAMePH8fgwYM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7h+/ToMBgOam5uh\n0Wgwb948q17I09MTYWF
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11c6f0518>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style(style='ticks'):\n",
|
||
|
" g = sns.factorplot(\"day\", \"total_bill\", \"sex\", data=tips, kind=\"box\")\n",
|
||
|
" g.set_axis_labels(\"Day\", \"Total Bill\");"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Joint distributions\n",
|
||
|
"\n",
|
||
|
"Similar to the pairplot we saw earlier, we can use ``sns.jointplot`` to show the joint distribution between different datasets, along with the associated marginal distributions:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaIAAAGmCAYAAAA+moB5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmUXGWdP/73Xere2ntfsgNZgDAGxIhflmEJgyjIJogw\nfvUrjjIcD+DBmZ8zeHSc71cBl6MOo3NQjzoKOuoMEpyICybsRsiwhUjCnrU73em1tlt11+f3R3VV\neu+qrtt9K93v1zmchE730093Ks/nPs+9/XlLQggBIiKigMhBT4CIiBY3FiIiIgoUCxEREQWKhYiI\niALFQkRERIFiISIiokCxEBERUaDUoCdAlRNCIJ1O+z5uMpmEJEm+j0tEVAkWomNIOp3Gfz+2G9Fo\nzLcxDSOHy89fj4aGBt/GJCKqBgvRMSYajSEWTwY9DSIi37AQzYG5OkJLpVIQYEcmIlpYWIjmwFwc\noQFAf18vYvEGxOO+DktEFCgWojkyF0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1495v22bNmCd7/73ejo\n6ACAMW24PM9DPp+HLMsoFApob28HAPz85z+HJEn44Ac/OGaszZs34w9/+AMymQyOHDmCyy67DDff\nfPOs5l/J/CaTzWbx9NNP46677gIA5PN5fPGLX8Qbb7wBx3Fw8803Y9OmTRM+LhaLlX9f+ppLtm7d\nihUrViASiVQ0Z0mSENa43E6F3xla9Pbu3Yu77roLp512Gj772c/iP/7jP/DhD38YX/ziF3HPPfeg\nqakJv/nNb/CNb3wDd955J9797nfjAx/4AADgX/7lX3D//ffjQx/6EACgt7cX//mf/wkAuOmmm/CF\nL3wBb3/725HP56FpGh5++GG89tpr2LJlCwYGBnDNNdfgjDPOAAC88soreOihh9DW1obrr78ezz//\nPE4//XQAQFNTU7k11mhbtmzBD37wgwnNg1euXIm77757zNt6e3uxZMmS8v93dHRg165dE8bct28f\nHMfBhz/8YRiGgQ9/+MO48sor0dHRgRtuuAHnn38+IpEIzj77bJx11lkAgOuuu27K7++uXbvw0EMP\nQdd1XHPNNbjgggtwyimnjHmf2267Dfv27ZvwsR/96EdxxRVXVDS/qWzduhVnnnlmubB85zvfwZln\nnok777wTmUwG11xzDc466yyEw+EJH/vNb34Tv/rVr5BIJHDvvfcCAAzDwPe//338+7//+4S8NZod\nFiJa9JYuXYrTTjsNAHD55ZfjJz/5Cc455xy8/vrr+NjHPgYhBDzPK1/9v/rqq7j77ruRTqeRz+dx\nzjnnlMd6z3veU/796aefjrvuuguXXXZZ+Qr+ueeew6WXXgqg2AD4jDPOwK5duxCLxbBhw4by5zjp\npJPQ1dVVLkRT7YIuu+yyMQnIfnBdF7t378aPf/xjGIaB6667Dm9/+9vR1NSEbdu24dFHH0UikcCt\nt96KLVu2zPj5zz777HIu2UUXXYTnnntuQiH65je/WfP8Vq1aNen7P/TQQ7j22mvL///UU0/hkUce\nKRcR27bR3d2NE044YcLH3nbbbbjtttvwve99Dz/5yU9wyy234Fvf+hY++tGPlndDQvDeT61YiIjG\nkSQJQgisXbsWP//5zyf8+e2334577rkH69atw+bNm7Fjx47yn0Wj0fLvb7zxRlxwwQV47LHHcP31\n1+P73//+hLFGL2KhUKj8e0VR4LpHn7aa6giotCMab9WqVRN2RB0dHeju7i7/f29vb7nwjX+/pqYm\n6LoOXdexceNGvPLKKxBCYMWKFWhsbARQLCovvPDCjIVo/G5tsuiX2267DXv37p3wfpPtiKaa32SF\naGhoCLt27cK//du/jXn
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11d25ef98>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" sns.jointplot(\"total_bill\", \"tip\", data=tips, kind='hex')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The joint plot can even do some automatic kernel density estimation and regression:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGmCAYAAAAzhPA+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XeYXWW58P/v2r1O39Nn0nsnyYQECCEQggoKYtcjStPX\nYzleevClHMVzBJTzUxSOB0GxoD8roBSFAAFCCKb3npAyfWZP3b2u9f4xmclMMr3sMnN/rouL7D17\nrXXvmWTf8zzrfu5H0TRNQwghhEgyXbIDEEIIIUASkhBCiBQhCUkIIURKkIQkhBAiJUhCEkIIkRIk\nIQkhhEgJhmQHMFSxWJzW1kCywxi07Gxb2sSbTrGCxDuW0ilWSL94XS5nskNISWmXkAwGfbJDGJJ0\nine4sWqahtfrGfZ1nc4MFEUZ8nHp9L2F9Io3nWK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oSU5uKqyh83nmTjrmpyM0wsn5lFpkOmgVJZ\nYY6Nwopy1leUEwzHOHymhQOnWjh0upmdRxvZebQRAFeWhTmTcpgzKZvZ5VlkOuT+nhjfJCGlsUAo\nxs9eOMjBUy2U5Nm54/1TOXi6OdlhiT5c2NS104wiMzOKirhpVSGNbWGOV3s4VuXhZK2Pt/fV8va+\nWgCKcmzMKs9iZnkWM0uzyMmwJPotCDGmJCGlqcoGL48/f4iGlgALp+XyhQ/OIxr2Jzss0Y9AwMem\n3d6LmrpeSAFml9mZWWqjzRelsS1MQ0uQZk+It/bW8tbejgSVm2Fhemkm04ozmFqcSVm+46K1T0Kk\nE0lIaUZVNTbuquYvb50
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11c3b0550>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.jointplot(\"total_bill\", \"tip\", data=tips, kind='reg');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Bar plots\n",
|
||
|
"\n",
|
||
|
"Time series can be plotted using ``sns.factorplot``. In the following example, we'll use the Planets data that we first saw in [Aggregation and Grouping](03.08-Aggregation-and-Grouping.ipynb):"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>method</th>\n",
|
||
|
" <th>number</th>\n",
|
||
|
" <th>orbital_period</th>\n",
|
||
|
" <th>mass</th>\n",
|
||
|
" <th>distance</th>\n",
|
||
|
" <th>year</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>Radial Velocity</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" <td>269.300</td>\n",
|
||
|
" <td>7.10</td>\n",
|
||
|
" <td>77.40</td>\n",
|
||
|
" <td>2006</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>Radial Velocity</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" <td>874.774</td>\n",
|
||
|
" <td>2.21</td>\n",
|
||
|
" <td>56.95</td>\n",
|
||
|
" <td>2008</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>Radial Velocity</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" <td>763.000</td>\n",
|
||
|
" <td>2.60</td>\n",
|
||
|
" <td>19.84</td>\n",
|
||
|
" <td>2011</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>Radial Velocity</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" <td>326.030</td>\n",
|
||
|
" <td>19.40</td>\n",
|
||
|
" <td>110.62</td>\n",
|
||
|
" <td>2007</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>Radial Velocity</td>\n",
|
||
|
" <td>1</td>\n",
|
||
|
" <td>516.220</td>\n",
|
||
|
" <td>10.50</td>\n",
|
||
|
" <td>119.47</td>\n",
|
||
|
" <td>2009</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" method number orbital_period mass distance year\n",
|
||
|
"0 Radial Velocity 1 269.300 7.10 77.40 2006\n",
|
||
|
"1 Radial Velocity 1 874.774 2.21 56.95 2008\n",
|
||
|
"2 Radial Velocity 1 763.000 2.60 19.84 2011\n",
|
||
|
"3 Radial Velocity 1 326.030 19.40 110.62 2007\n",
|
||
|
"4 Radial Velocity 1 516.220 10.50 119.47 2009"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"planets = sns.load_dataset('planets')\n",
|
||
|
"planets.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkEAAAEWCAYAAABhZ0N/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGh9JREFUeJzt3X1QVNcd//HPuouNQZEislK2gxbDaCbVjHVSzdhWwar4\nMIgPHeNjxarTJhIN1FY0MVNN6zRNZX61TWBqYlsTnfgUo6IxrkmstiXGmQRNJKM7tiK6q4gYBauw\n3t8f/rK/oKZZZB+A8379xR53z34vx+t8PPfce2yWZVkCAAAwTIdoFwAAABANhCAAAGAkQhAAADAS\nIQgAABiJEAQAAIxECAIAAEYKawjyer2aOXOmxowZo3Hjxumvf/2rJOny5cvKzc3VyJEjNWfOHF25\nciXwmeLiYo0YMUJZWVk6ePBgOMsDAAAGs4XzOUEXLlxQdXW1+vbtq7q6Ok2YMEF/+tOftHXrVsXH\nx2vu3LkqKSnRZ599poKCAp08eVIFBQXavHmzvF6vZs+erb1798pms4WrRAAAYKiwzgR1795dffv2\nlSTFxsYqLS1NPp9PbrdbOTk5kqScnBzt27dPkrR//36NHj1aDodDLpdLqampKi8vD2eJAADAUBFb\nE3TmzBlVVFSof//+unjxohITEyXdCko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Ouvv64NGzbo/vvvV58+fbR169bAJqgAAABtUVAhqKGhockTooN9\nWjQAAEBrFdSaoOHDh2vWrFnKysqSJO3duzew3QUAAEBbFFQI+vnPf649e/bo8OHDcjgcmjlzpoYP\nHx7u2gAAAMIm6F3kR40
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11ade0dd8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" g = sns.factorplot(\"year\", data=planets, aspect=2,\n",
|
||
|
" kind=\"count\", color='steelblue')\n",
|
||
|
" g.set_xticklabels(step=5)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We can learn more by looking at the *method* of discovery of each of these planets:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABT4AAAEWCAYAAABPHojpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XlUVdX///HXZVIGJ0BxRsNAcx5SzMoBwxxQcSjNr6Y5\nZqSYI2mm4ZDjx7HUFFMzLUVUEq2PU+UnDTPLzEq9mrPiWEyCXO7vDxf3JwlclMnw+VjLtbj7nLP3\n+5x7/+nVPnsbzGazWQAAAAAAAABQiNgUdAEAAAAAAAAAkNsIPgEAAAAAAAAUOgSfAAAAAAAAAAod\ngk8AAAAAAAAAhQ7BJwAAAAAAAIBCh+ATAAAAAAAAQKGTp8Hn22+/rWeeeUYBAQGWtr/++kuvvfaa\n2rRpo/79+ys2NtZybOnSpfL391fbtm21b9++vCwNAAAAAAAAQC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\n4OBg3b59W5999pn+7//+T/PmzbMszgoAAADkJmYxAUD2lCrjKLfyzgVdBgA8sqwGn6GhoVq8eLFG\njhwpDw8PTZo0Se+++642btyYH/UBAADgMWM0GnV44XJ5upVO137m+lXpzQHMYgIAAEC22Fg7ITEx\nUV5eXpbPzZo1U3Jycp4WBQAAgMebp1tpeXmUS/fvn0EoAAAAkBWrwWfJkiX1+++/y2AwSJK2bt3K\nWp8AAAAAAAAAHmlWX3WfNGmSxo4dqxMnTqhRo0by9PTU7Nmz86M2AAAAAAAA5IGs1tR+WKzFjUeN\n1eAzPj5e69atU0JCglJ
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11bd8d668>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" g = sns.factorplot(\"year\", data=planets, aspect=4.0, kind='count',\n",
|
||
|
" hue='method', order=range(2001, 2015))\n",
|
||
|
" g.set_ylabels('Number of Planets Discovered')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"For more information on plotting with Seaborn, see the [Seaborn documentation](http://seaborn.pydata.org/), a [tutorial](http://seaborn.pydata.org/\n",
|
||
|
"tutorial.htm), and the [Seaborn gallery](http://seaborn.pydata.org/examples/index.html)."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Example: Exploring Marathon Finishing Times\n",
|
||
|
"\n",
|
||
|
"Here we'll look at using Seaborn to help visualize and understand finishing results from a marathon.\n",
|
||
|
"I've scraped the data from sources on the Web, aggregated it and removed any identifying information, and put it on GitHub where it can be downloaded\n",
|
||
|
"(if you are interested in using Python for web scraping, I would recommend [*Web Scraping with Python*](http://shop.oreilly.com/product/0636920034391.do) by Ryan Mitchell).\n",
|
||
|
"We will start by downloading the data from\n",
|
||
|
"the Web, and loading it into Pandas:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# !curl -O https://raw.githubusercontent.com/jakevdp/marathon-data/master/marathon-data.csv"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>age</th>\n",
|
||
|
" <th>gender</th>\n",
|
||
|
" <th>split</th>\n",
|
||
|
" <th>final</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:05:38</td>\n",
|
||
|
" <td>02:08:51</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>32</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:26</td>\n",
|
||
|
" <td>02:09:28</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:49</td>\n",
|
||
|
" <td>02:10:42</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>38</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:16</td>\n",
|
||
|
" <td>02:13:45</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:32</td>\n",
|
||
|
" <td>02:13:59</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" age gender split final\n",
|
||
|
"0 33 M 01:05:38 02:08:51\n",
|
||
|
"1 32 M 01:06:26 02:09:28\n",
|
||
|
"2 31 M 01:06:49 02:10:42\n",
|
||
|
"3 38 M 01:06:16 02:13:45\n",
|
||
|
"4 31 M 01:06:32 02:13:59"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data = pd.read_csv('marathon-data.csv')\n",
|
||
|
"data.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"By default, Pandas loaded the time columns as Python strings (type ``object``); we can see this by looking at the ``dtypes`` attribute of the DataFrame:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 24,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"age int64\n",
|
||
|
"gender object\n",
|
||
|
"split object\n",
|
||
|
"final object\n",
|
||
|
"dtype: object"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 24,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data.dtypes"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Let's fix this by providing a converter for the times:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>age</th>\n",
|
||
|
" <th>gender</th>\n",
|
||
|
" <th>split</th>\n",
|
||
|
" <th>final</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:05:38</td>\n",
|
||
|
" <td>02:08:51</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>32</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:26</td>\n",
|
||
|
" <td>02:09:28</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:49</td>\n",
|
||
|
" <td>02:10:42</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>38</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:16</td>\n",
|
||
|
" <td>02:13:45</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:32</td>\n",
|
||
|
" <td>02:13:59</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" age gender split final\n",
|
||
|
"0 33 M 01:05:38 02:08:51\n",
|
||
|
"1 32 M 01:06:26 02:09:28\n",
|
||
|
"2 31 M 01:06:49 02:10:42\n",
|
||
|
"3 38 M 01:06:16 02:13:45\n",
|
||
|
"4 31 M 01:06:32 02:13:59"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def convert_time(s):\n",
|
||
|
" h, m, s = map(int, s.split(':'))\n",
|
||
|
" return pd.datetools.timedelta(hours=h, minutes=m, seconds=s)\n",
|
||
|
"\n",
|
||
|
"data = pd.read_csv('marathon-data.csv',\n",
|
||
|
" converters={'split':convert_time, 'final':convert_time})\n",
|
||
|
"data.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"age int64\n",
|
||
|
"gender object\n",
|
||
|
"split timedelta64[ns]\n",
|
||
|
"final timedelta64[ns]\n",
|
||
|
"dtype: object"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 26,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data.dtypes"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"That looks much better. For the purpose of our Seaborn plotting utilities, let's next add columns that give the times in seconds:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>age</th>\n",
|
||
|
" <th>gender</th>\n",
|
||
|
" <th>split</th>\n",
|
||
|
" <th>final</th>\n",
|
||
|
" <th>split_sec</th>\n",
|
||
|
" <th>final_sec</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:05:38</td>\n",
|
||
|
" <td>02:08:51</td>\n",
|
||
|
" <td>3938.0</td>\n",
|
||
|
" <td>7731.0</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>32</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:26</td>\n",
|
||
|
" <td>02:09:28</td>\n",
|
||
|
" <td>3986.0</td>\n",
|
||
|
" <td>7768.0</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:49</td>\n",
|
||
|
" <td>02:10:42</td>\n",
|
||
|
" <td>4009.0</td>\n",
|
||
|
" <td>7842.0</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>38</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:16</td>\n",
|
||
|
" <td>02:13:45</td>\n",
|
||
|
" <td>3976.0</td>\n",
|
||
|
" <td>8025.0</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:32</td>\n",
|
||
|
" <td>02:13:59</td>\n",
|
||
|
" <td>3992.0</td>\n",
|
||
|
" <td>8039.0</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" age gender split final split_sec final_sec\n",
|
||
|
"0 33 M 01:05:38 02:08:51 3938.0 7731.0\n",
|
||
|
"1 32 M 01:06:26 02:09:28 3986.0 7768.0\n",
|
||
|
"2 31 M 01:06:49 02:10:42 4009.0 7842.0\n",
|
||
|
"3 38 M 01:06:16 02:13:45 3976.0 8025.0\n",
|
||
|
"4 31 M 01:06:32 02:13:59 3992.0 8039.0"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data['split_sec'] = data['split'].astype(int) / 1E9\n",
|
||
|
"data['final_sec'] = data['final'].astype(int) / 1E9\n",
|
||
|
"data.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"To get an idea of what the data looks like, we can plot a ``jointplot`` over the data:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAbUAAAGmCAYAAAD76BroAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXu8FVX5/z9rzcze5wqH60EhyQQKL3jrReQFCwwCvgiY\naGahmJa9NF7aT0WixCy+kvRSK/sWfutb3r6pKWAoGEKl+NU0L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EY2NjRg1alTGdgDYt29fsM8wDAwaNAhHjhwp9m0RBNHHPPvs\ns/j85z+PmTNn4p577sl6THNzM6655hqcd955uPDCC/HOO+8E+1paWrBkyRLMmjULc+bMwWuvvdZb\nU0/hBz/4AWbMmIF58+bhzTff7JM5lBNFN2qcc6xfvx7PPvsstm/fjnfeeQdf+tKXsHXrVjz++OMY\nPnw4Vq1a1WPXK7R8DEEQhSGEKMq4Uspunfv9738fv/rVr/DEE0/gySefxK5duzKO+8UvfoGJEyfi\n97//PVatWoUf/OAHwb6VK1finHPOwaZNm/D444/juOOO6/J8usozzzyD3bt3Y/Pmzbj11luxYsWK\nXp9DudFrFUVqamowefJkbNu2LWUt7cILL8RVV10FQHtgH374YbCvoaEB9fX1GdsbGxtRX18PABg5\ncmRwnBACra2tqKur66W7IojSYe/evbjiiitwwgkn4I033sD48eNx++23IxqNYufOnVi1ahXa29sx\nZMgQrFq1CsOHD8fvfvc7PPzww3BdF8cccwxWr16NaDSKZcuWIRKJ4M0338Tpp5+OadOmYeXKlWCM\ngTGGBx54AFVVVfjhD3+I5557DowxXHXVVZg9ezZeeukl/PSnP8WQIUPw9ttv48QTT8Tq1asBANOm\nTcPs2bPx/PPP44orrsDs2bO7dK/bt2/H2LFjMXr0aADAnDlzsHXr1gzDtGvXLnzta18DAHzsYx/D\n3r17cejQIUQiEbz88svBF2rTNFFTUwMAeOihh8AYw0UXXZQy1rp16/D000+jpaUF+/btw9y5c3HN\nNdd0af4+W7duxfz58wEAJ598MlpaWnDgwAEMHz68W+MOZIpq1A4dOgTLslBbW4t4PI7nn38eX/va\n17B//36MGDECAPD0009jwoQJAPQ/+Ouvvx6XXXYZGhsbsXv3bkyaNAmMMdTW1mL79u046aSTsH79\nenzlK18Jzlm3bh1OPvlkPPXUU5gyZUoxb4kgSpp3330Xt912G0455RR8+9vfxv/+7//iK1/5Cr7/\n/e/j5z//OYYMGYKNGzfijjvuwH/+539ixowZWLhwIQDgrrvuwqOPPopLLrkEgP7y+MgjjwAArrrq\nKqxYsQKnnnoqYrEYIpEINm/ejH/+85/YsGEDDh48iAsuuACTJ08GALz11lt48sknMWLECFx88cX4\n29/+htNOOw0AMGTIEKxduzZj7hs2bMCvfvWrjJJQxxxzDH784x+nbMu2VLFjx46MMT/xiU/g6aef\nxumnn47t27fjww8/RENDAzjnGDJkCJYtW4a33noLJ554IpYvX46Kigp88YtfzPl8d+zYgSeffBLR\naBQXXHABPvvZz+KEE05IOea6667De++9l3HuZZddhnnz5qVsCy+f+PfR2NhIRq0bFNWo7d+/Hzfd\ndBOklJBSYvbs2TjnnHNw44034s033wTnHKNHj8att94KABg3blwQ3zZNEytWrAj+gd98881YtmwZ\nEokEpk6dGqgoFy5ciBtuuAEzZsxAXV0d7rjjjmLeEkGUNEcffTROOeUUAMB5552HBx54AGeddRbe\nfvttXH755VBKQUqJkSNHAgD+8Y9/4Mc//jGam5sRi8Vw1llnBWN9/vOfDz6fdtppuO222zB37lzM\nmDED9fX1eOWVVzBnzhw
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11b646ac8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with sns.axes_style('white'):\n",
|
||
|
" g = sns.jointplot(\"split_sec\", \"final_sec\", data, kind='hex')\n",
|
||
|
" g.ax_joint.plot(np.linspace(4000, 16000),\n",
|
||
|
" np.linspace(8000, 32000), ':k')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The dotted line shows where someone's time would lie if they ran the marathon at a perfectly steady pace. The fact that the distribution lies above this indicates (as you might expect) that most people slow down over the course of the marathon.\n",
|
||
|
"If you have run competitively, you'll know that those who do the opposite—run faster during the second half of the race—are said to have \"negative-split\" the race.\n",
|
||
|
"\n",
|
||
|
"Let's create another column in the data, the split fraction, which measures the degree to which each runner negative-splits or positive-splits the race:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>age</th>\n",
|
||
|
" <th>gender</th>\n",
|
||
|
" <th>split</th>\n",
|
||
|
" <th>final</th>\n",
|
||
|
" <th>split_sec</th>\n",
|
||
|
" <th>final_sec</th>\n",
|
||
|
" <th>split_frac</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:05:38</td>\n",
|
||
|
" <td>02:08:51</td>\n",
|
||
|
" <td>3938.0</td>\n",
|
||
|
" <td>7731.0</td>\n",
|
||
|
" <td>-0.018756</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>32</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:26</td>\n",
|
||
|
" <td>02:09:28</td>\n",
|
||
|
" <td>3986.0</td>\n",
|
||
|
" <td>7768.0</td>\n",
|
||
|
" <td>-0.026262</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:49</td>\n",
|
||
|
" <td>02:10:42</td>\n",
|
||
|
" <td>4009.0</td>\n",
|
||
|
" <td>7842.0</td>\n",
|
||
|
" <td>-0.022443</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>38</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:16</td>\n",
|
||
|
" <td>02:13:45</td>\n",
|
||
|
" <td>3976.0</td>\n",
|
||
|
" <td>8025.0</td>\n",
|
||
|
" <td>0.009097</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:32</td>\n",
|
||
|
" <td>02:13:59</td>\n",
|
||
|
" <td>3992.0</td>\n",
|
||
|
" <td>8039.0</td>\n",
|
||
|
" <td>0.006842</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" age gender split final split_sec final_sec split_frac\n",
|
||
|
"0 33 M 01:05:38 02:08:51 3938.0 7731.0 -0.018756\n",
|
||
|
"1 32 M 01:06:26 02:09:28 3986.0 7768.0 -0.026262\n",
|
||
|
"2 31 M 01:06:49 02:10:42 4009.0 7842.0 -0.022443\n",
|
||
|
"3 38 M 01:06:16 02:13:45 3976.0 8025.0 0.009097\n",
|
||
|
"4 31 M 01:06:32 02:13:59 3992.0 8039.0 0.006842"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data['split_frac'] = 1 - 2 * data['split_sec'] / data['final_sec']\n",
|
||
|
"data.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Where this split difference is less than zero, the person negative-split the race by that fraction.\n",
|
||
|
"Let's do a distribution plot of this split fraction:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"metadata": {
|
||
|
"collapsed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3KwdO3Zo4cKFqq+v14IFC1RdXS1JOnv2rA4ePKi6ujrt3LlTW7dulW3bkqQtW7aoqqpK9fX1amlp\n0bFjx8Z264A/wtzvAEw2pMPvKSkpkvr22q9cuSJJamxsVEVFhSSpoqJCDQ0NkqTDhw+rpKRELpdL\ns2bNUlZWlpqbmxUIBBQOh5WbmytJKi8vj6wDAABGbkih3tvbq/Lyct1555268847lZubqwsXLsjr\n9UqSfD6fgsGgJMmyLM2cOTOyrt/vl2VZsixLM2bM6NcOAABGx5BC3el0XnPo/T//8z/lcDiuWeaP\n/wYAALHlupGF09LS9NWvflXHjh3TtGnT1NbWJq/Xq0AgoIyMDEl9e+Dnz5+PrNPa2iq/39+v3bIs\n+f3+qO85dWqqXK6kGylzXPL5PPEuAZKczr4fn6aMR3Jyr9LcQbnTJg/Y3xVOltN5kzxx6neqR16v\nR1OmDP7vbcpYmICxmPiihnowGNRNN90kj8ejy5cv6xe/+IVWrFih/Px87d+/XytWrFBNTY0KCgok\nSfn5+Vq3bp0ef/xxWZalc+fOKTc3Vw6HQx6PR83NzZo3b55qa2tVWVkZtcCLFztHvpVx5vN5FAiE\noi+IMdfba8vpdBgzHu3tIXWEu9WrywP2h8M9cjqvalJKfPo7w91qawupp2fgg4J8NsYPxmL8GMmP\nq6ihHggE9L3vfU+9vb3q7e1VSUmJ7rnnHt16661as2aN9u3bp8zMTG3btk2SlJ2dreLiYpWWlsrl\ncmnz5s2RQ/ObNm3S+vXr1d3drby8POXl5Q27cGA4mppO8uUFwFgO+7P7zcYpE758CZHxZSKNh23b\nCoXaB+0Phdr1f/5vWKl
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11bb754a8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.distplot(data['split_frac'], kde=False);\n",
|
||
|
"plt.axvline(0, color=\"k\", linestyle=\"--\");"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"251"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sum(data.split_frac < 0)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Out of nearly 40,000 participants, there were only 250 people who negative-split their marathon.\n",
|
||
|
"\n",
|
||
|
"Let's see whether there is any correlation between this split fraction and other variables. We'll do this using a ``pairgrid``, which draws plots of all these correlations:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 32,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAwcAAALGCAYAAAAQm+3qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXuQXNdV7//Z+zy6z3TPjOalhyUZK9ZblsK9NjiO7yXG\nhpgQnGBSRQiU/yApO1VUQuzCUJACUqSKQEFRGIo/kFJUGZJUiqrIzoVfAg5xyM2FlBMik0i2LFl2\n5FiS9Zj39OP0ee39++Oc7ume6XlJ8+rR/lSpRtPTZ/fu06vP2Wuv9V1LaK01BoPBYDAYDAaD4aZH\nrvUEDAaDwWAwGAwGw/rAOAcGg8FgMBgMBoMBMM6BwWAwGAwGg8FgyDDOgcFgMBgMBoPBYACMc2Aw\nGAwGg8FgMBgyjHNgMBgMBoPBYDAYgHXoHHzyk5/kne98Jw899FDjscnJST784Q/z4IMP8pGPfIRS\nqdT429GjR3n3u9/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GlaCwUv/RXdcAiFBKzwBo1YPgeUx\nZHa9NgTnywFX/dQxAHiluIf9ZehSPpHtMda9m92LGKN+MxwPFEoDaA5Ovko+HCW2JAU1xduyHbC+\nYBQpBHbJx4gyDWvF+XJANTP8M8U97CtDj66xqbubM4XdDZveMfYKKhxD2hYyKLO5FjO26RAAERAp\nSPd64aofMRkmQJpbfq0c4FuCvb2eEeJvMOb6PBcrXK9fezP/gVeKe7g3HEXGCUpaoDV7Sud43TnU\ncozprrxx6RjnYGpqiueff55///d/p7u7m0984hP80z/9U8Pw68z8fS6Ghm5Ml3AzH7+ar31tqsI3\nz0/wMypIHQMAIVFCcqL
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11aeb5908>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"g = sns.PairGrid(data, vars=['age', 'split_sec', 'final_sec', 'split_frac'],\n",
|
||
|
" hue='gender', palette='RdBu_r')\n",
|
||
|
"g.map(plt.scatter, alpha=0.8)\n",
|
||
|
"g.add_legend();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"It looks like the split fraction does not correlate particularly with age, but does correlate with the final time: faster runners tend to have closer to even splits on their marathon time.\n",
|
||
|
"(We see here that Seaborn is no panacea for Matplotlib's ills when it comes to plot styles: in particular, the x-axis labels overlap. Because the output is a simple Matplotlib plot, however, the methods in [Customizing Ticks](04.10-Customizing-Ticks.ipynb) can be used to adjust such things if desired.)\n",
|
||
|
"\n",
|
||
|
"The difference between men and women here is interesting. Let's look at the histogram of split fractions for these two groups:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 33,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png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s6cialTpzpVDxE5pD8zgFgujo5A24gLUcLDgpiI\nnDeqIH7yySdx2WWXOVULETnIvizdFpg84uMimhXE/Wk29SCqhrJvAOXzeTz99NP48pe/XNbjx7OC\nrFZ4YQyAN8bhhTEA7o7j4N4DAICTph2H5ubQUR/XnmsB9gFZKXnUer3w+fDCGABvjMMLYxiPsoP4\n2WefxamnnopJk8q7Z1Tvy9G9tKS+3sfhhTEA7o9ja+c7UCQFDVILotHUUR8n5RUAwJ7eziPW6/Y4\nKsELYwC8MQ4vjAGo0valJ554AkuWVLfNGRFVhilMHEx2odU/CYqsjPjYoXvE7K5FVA1lBXE6ncbz\nzz/P1dJEdSqeS0IXBiK+cMnHhn3WZes4u2sRVUVZl6aDwSA2bdrkdC1E5JCBrLXwKqwESz5WkRUE\nfQHEdQYxUTWwsxbRBDCQsS4zh9SjL9IaLqKGkcgn4VAHXCIahkFMNAEMZKwZcaM/Utbjw2oYeaEj\nY2SdLIuIwCAmmhAGCguvmoLNZT0+Upg5c8EWkfMYxEQTwEAmCgBoChy9teVw9srpaIbdtYicxiAm\nmgD6s1EokoyQr/RiLcA6+AEA+tL9TpZFRGAQE00I0UwUEV+k7MPOA4ofAJDM8jhEIqcxiIk8Tjd1\nxHIJRHzlrZgGAFVRAQCpfNqpsoiogEFM5HHRbAwCAuEymnnYNFkDwCAmqgYGMZHH2Qu1QmU087Bp\nhRlxltuXiBzHICbyuIG
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11bdb3a58>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.kdeplot(data.split_frac[data.gender=='M'], label='men', shade=True)\n",
|
||
|
"sns.kdeplot(data.split_frac[data.gender=='W'], label='women', shade=True)\n",
|
||
|
"plt.xlabel('split_frac');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The interesting thing here is that there are many more men than women who are running close to an even split!\n",
|
||
|
"This almost looks like some kind of bimodal distribution among the men and women. Let's see if we can suss-out what's going on by looking at the distributions as a function of age.\n",
|
||
|
"\n",
|
||
|
"A nice way to compare distributions is to use a *violin plot*"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 34,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfsAAAFmCAYAAABqczNPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl0XPV9///nSKN9X2ZGu2RJ1uJ9kbEBY4MNtolJsYmp\n80tJE8gJyfl+U75w8g0p6SFpkxDapIEc2qZfnJSwNKmbsBUwDcYO2NjYBu82tixr32ckjXbJWmbu\n7w/Zwq6xESDpjq5ej3N0PMv1zFu2NK/7We7nYzMMw0BEREQsK8jsAkRERGRiKexFREQsTmEvIiJi\ncQp7ERERi1PYi4iIWJzCXkRExOJMD/vdu3ezbt061q5dy5YtWy57vqenh29+85vcfvvtfP7zn+fF\nF180oUoREZGpy2bmdfZ+v5+1a9fy9NNP43Q62bRpE4899hh5eXmjxzz55JP09PTw7W9/G6/Xy623\n3srevXux2+1mlS0iIjKlmNqyP378ONnZ2aSnpxMSEsL69evZuXPnJcfYbDZ6e3sB6O3tJT4+XkEv\nIiLyCZga9m63m9TU1NH7LpcLj8dzyTF/8Rd/QXl5OcuXL+f222/ne9/73mSXKSIiMqWZPmb/cfbs\n2cOsWbPYs2cPL7/8Mj/84Q9HW/oiIiLy8UwNe5fLRWNj4+h9t9uN0+m85JgXX3yRW265BYCsrCwy\nMjKorKz82NceHvaNb7EiIiJTlKmD33PnzqW2tpaGhgYcDgfbtm3jscceu+SYtLQ09u3bx+LFi2lt\nbaW6uprMzMyPfe329r6JK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|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.violinplot(\"gender\", \"split_frac\", data=data,\n",
|
||
|
" palette=[\"lightblue\", \"lightpink\"]);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"This is yet another way to compare the distributions between men and women.\n",
|
||
|
"\n",
|
||
|
"Let's look a little deeper, and compare these violin plots as a function of age. We'll start by creating a new column in the array that specifies the decade of age that each person is in:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 35,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>age</th>\n",
|
||
|
" <th>gender</th>\n",
|
||
|
" <th>split</th>\n",
|
||
|
" <th>final</th>\n",
|
||
|
" <th>split_sec</th>\n",
|
||
|
" <th>final_sec</th>\n",
|
||
|
" <th>split_frac</th>\n",
|
||
|
" <th>age_dec</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:05:38</td>\n",
|
||
|
" <td>02:08:51</td>\n",
|
||
|
" <td>3938.0</td>\n",
|
||
|
" <td>7731.0</td>\n",
|
||
|
" <td>-0.018756</td>\n",
|
||
|
" <td>30</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>32</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:26</td>\n",
|
||
|
" <td>02:09:28</td>\n",
|
||
|
" <td>3986.0</td>\n",
|
||
|
" <td>7768.0</td>\n",
|
||
|
" <td>-0.026262</td>\n",
|
||
|
" <td>30</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:49</td>\n",
|
||
|
" <td>02:10:42</td>\n",
|
||
|
" <td>4009.0</td>\n",
|
||
|
" <td>7842.0</td>\n",
|
||
|
" <td>-0.022443</td>\n",
|
||
|
" <td>30</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>38</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:16</td>\n",
|
||
|
" <td>02:13:45</td>\n",
|
||
|
" <td>3976.0</td>\n",
|
||
|
" <td>8025.0</td>\n",
|
||
|
" <td>0.009097</td>\n",
|
||
|
" <td>30</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>31</td>\n",
|
||
|
" <td>M</td>\n",
|
||
|
" <td>01:06:32</td>\n",
|
||
|
" <td>02:13:59</td>\n",
|
||
|
" <td>3992.0</td>\n",
|
||
|
" <td>8039.0</td>\n",
|
||
|
" <td>0.006842</td>\n",
|
||
|
" <td>30</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" age gender split final split_sec final_sec split_frac age_dec\n",
|
||
|
"0 33 M 01:05:38 02:08:51 3938.0 7731.0 -0.018756 30\n",
|
||
|
"1 32 M 01:06:26 02:09:28 3986.0 7768.0 -0.026262 30\n",
|
||
|
"2 31 M 01:06:49 02:10:42 4009.0 7842.0 -0.022443 30\n",
|
||
|
"3 38 M 01:06:16 02:13:45 3976.0 8025.0 0.009097 30\n",
|
||
|
"4 31 M 01:06:32 02:13:59 3992.0 8039.0 0.006842 30"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 35,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data['age_dec'] = data.age.map(lambda age: 10 * (age // 10))\n",
|
||
|
"data.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 36,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfsAAAFhCAYAAAB3dgP3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd0W9eVL/7vRSVIsPdeRYoUSRWqF9rqsmTLckkkl3hs\nz++tJOuXeMbJyqS85cwktmfezKS8OG3GEzt2HCuyZBWrWLYoWRLVSFGkKFLsvVeAIAmAJEDgvj9A\nQOxEuZcgr/ZnLa8lguDFuQZw9z3n7LMPw7IsC0IIIYQIlsjdDSCEEEIIvyjYE0IIIQJHwZ4QQggR\nOAr2hBBCiMBRsCeEEEIEjoI9IYQQInASdzeALz09g+5uAiGEEDJvgoO9Z/wd9ewJIYQQgaNgTwgh\nhAgcBXtCCCFE4CjYE0IIIQJHwZ4QQggROAr2hBBCiMBRsCeEEEIEjoI9IYQQInAU7AkhhJB58K//\n+jOUl993y2tTsCeEEEIETrDlcgkhhBAuqFS9+Jd/+d8QiUTw8fFFXFw8BgcHUVtbDQD4h3/4PpYs\nScFLLx1EUlIyGhvr8cgj2/B3f/f3KCjIx3/91+/g6+sHrdZSxr2/X4N/+7efY2hoCJ6envjJT/4F\ntbXV+OMffwupVIpvf/s1pKdncHoO1LMnhBBCZvHRRx/g2WcP4je/+SPi4xNw8+Z1mEwm/O537+Jf\n/uVt/OY3vwQ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Ngjw/\nQsgDs93QuzXYi8VivPHGG3j11VfBsiyeffZZJCYm4siRI2AYBgcPHnRn8+x29epFABBksBc6azAU\n6nQFzXoRQgA3B3sAyM7
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11bd81c18>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"men = (data.gender == 'M')\n",
|
||
|
"women = (data.gender == 'W')\n",
|
||
|
"\n",
|
||
|
"with sns.axes_style(style=None):\n",
|
||
|
" sns.violinplot(\"age_dec\", \"split_frac\", hue=\"gender\", data=data,\n",
|
||
|
" split=True, inner=\"quartile\",\n",
|
||
|
" palette=[\"lightblue\", \"lightpink\"]);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Looking at this, we can see where the distributions of men and women differ: the split distributions of men in their 20s to 50s show a pronounced over-density toward lower splits when compared to women of the same age (or of any age, for that matter).\n",
|
||
|
"\n",
|
||
|
"Also surprisingly, the 80-year-old women seem to outperform *everyone* in terms of their split time. This is probably due to the fact that we're estimating the distribution from small numbers, as there are only a handful of runners in that range:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 38,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"7"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 38,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"(data.age > 80).sum()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Back to the men with negative splits: who are these runners? Does this split fraction correlate with finishing quickly? We can plot this very easily. We'll use ``regplot``, which will automatically fit a linear regression to the data:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 37,
|
||
|
"metadata": {
|
||
|
"collapsed": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsQAAAFeCAYAAACCQAk7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmUXPV16PvvqVNj19izepBaUmsCLDMbjGVhm0WEQuww\nyIH7Yq9gO8srw2IltoMdHLC9DMG5z8+yr/VunmMTR8Ek5oKNsB3wBDjIIMQgAZoQktDQ6nmoruqa\nT53h/VGDqnpSt7pb3a3an7VYdHdVnfPratWvdu2zf/unWJZlIYQQQgghRIWyzfcAhBBCCCGEmE8S\nEAshhBBCiIomAbEQQgghhKhoEhALIYQQQoiKJgGxEEIIIYSoaBIQCyGEEEKIiiYBsbigvfrqq3zy\nk5+c03Ps2LGDdevW8cwzz5T9fPv27axbt47u7u45Pb8QQpxvcz236rrOFVdcwcjISPFnt99+O5/5\nzGeK3584cYKPfOQjczYGUVkkIBYXPEVR5vwcTU1N/OpXvyr72bPPPkswGJzzcwshxHyYy7nVbrdz\n5ZVX8sYbbwAQDoexLIsTJ06QyWQAeP3119mwYcOcjUFUFvt8D0CIgm9961v85je/obq6mvr6em64\n4QZuueUWnnrqKR555BEsy+KSSy7hK1/5Ck6nkw0bNnDTTTexZ88e7HY73/nOd2hpaeHFF1/kn/7p\nn3C5XKxYsaJ4/I6ODr72ta8RiUTweDzcf//9rFu3jnvvvZfh4WFOnz7NPffcw4c+9CEATNPktttu\nGzPpf/vb32b58uVlP7vqqqvYs2cP6XQat9tNd3c3Xq8Xn88310+bEEJMarHOrddccw179+7l+uuv\nZ9euXVx33XX09PTw6quv8sEPfpA9e/YUjynETEmGWCwIv/vd73jjjTd45pln+P73v8+hQ4cAOHbs\nGE888Q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hRBCCCFERZOAWAghhBBCVDQJ\niIUQQgghREWTgFgIIYQQQlQ0CYiFEEIIIURFk4BYCCGEEEJUNAmIhRBCCCFERZOAWAghhBBCVDQJ\niIUQQgghREWTgFgIIYQQQlQ0CYiFEEIIIURFk4BYCCGEEEJUtFkJiHfu3MlNN93Epk2b+P73vz/u\nfV555RVuueUW/uiP/ohPfvKTs3FaIYQQQgghZsw+0wOYpskDDzzA9u3baWhoYMuWLdxwww20t7cX\n7xOLxfj617/OD3/4QxobGwmHwzM9rRBCCCGEELNixhniffv20dbWRktLCw6Hg5tvvpnnnnuu7D6/\n+MUv+IM/+AMaGxsBqKmpmelphRBCCCGEmBUzDoj7+vpoamoqft/Y2Eh/f3/ZfU6ePEk0GuWTn/wk\nt99+O0899dRMTyuEEEIIIcSsmHHJxFQYhsGhQ4f493//d5LJJHfeeSeXX345bW1t5+P0QgghhBBC\nTGjGAXFjYyPd3d3F7/v6+mhoaBhzn+rqalwuFy6Xi6uuuorDhw9PKSCur/fPdIjnjYx1bshY585i\nGu9iGutisZieUxnr3FhMY4XFNV4Z6+Iy44B4/fr1dHR00NXVRX19PU8//TRbt24tu88NN9zAgw8+\niGEYaJrGvn37+NSnPjWl4w8MxGY6xPOivt4vY50DMta5s5jGu9jGulgspudUxjr7FtNYYXGNV8Y6\nN+Zyfp1xQKyqKvfffz+f/vSnsSyLLVu20N7ezmOPPYaiKNxxxx20t7ezYcMGPvaxj2Gz2fiTP/kT\nVq1aNRvjF0IIIYQQYkZmpYZ448aNbNy4sexnd955Z9n3n/nMZ/jMZz4zG6cTQgghhBBi1shOdUIs\nEJ2axrbBXjo1bb6HIoQ
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x11e0dfba8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"g = sns.lmplot('final_sec', 'split_frac', col='gender', data=data,\n",
|
||
|
" markers=\".\", scatter_kws=dict(color='c'))\n",
|
||
|
"g.map(plt.axhline, y=0.1, color=\"k\", ls=\":\");"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Apparently the people with fast splits are the elite runners who are finishing within ~15,000 seconds, or about 4 hours. People slower than that are much less likely to have a fast second split."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"<!--NAVIGATION-->\n",
|
||
|
"< [Geographic Data with Basemap](04.13-Geographic-Data-With-Basemap.ipynb) | [Contents](Index.ipynb) | [Further Resources](04.15-Further-Resources.ipynb) >"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"anaconda-cloud": {},
|
||
|
"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
|
||
|
}
|