mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
356 lines
193 KiB
Python
356 lines
193 KiB
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",
|
|||
|
"< [Simple Line Plots](04.01-Simple-Line-Plots.ipynb) | [Contents](Index.ipynb) | [Visualizing Errors](04.03-Errorbars.ipynb) >"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Simple Scatter Plots"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Another commonly used plot type is the simple scatter plot, a close cousin of the line plot.\n",
|
|||
|
"Instead of points being joined by line segments, here the points are represented individually with a dot, circle, or other shape.\n",
|
|||
|
"We’ll start by setting up the notebook for plotting and importing the functions we will use:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 1,
|
|||
|
"metadata": {
|
|||
|
"collapsed": true
|
|||
|
},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"%matplotlib inline\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"plt.style.use('seaborn-whitegrid')\n",
|
|||
|
"import numpy as np"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Scatter Plots with ``plt.plot``\n",
|
|||
|
"\n",
|
|||
|
"In the previous section we looked at ``plt.plot``/``ax.plot`` to produce line plots.\n",
|
|||
|
"It turns out that this same function can produce scatter plots as well:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 2,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE+tJREFUeJzt3WtsFNUfxvGnWCzaLYoaX9BoaRobY1SSlhcaU9yNaYLX\niBZdmBaiJEaIhghR4mVF3JCi0egLIaKYVItaLpJ4iZdAIFWJjWUVDBiNgQ1iaYyChm691Lrzf8G/\nW9ZuaXd2uzN75vtJeLEz093DpDycPed3zpTYtm0LAGCsSW43AAAwsQh6ADAcQQ8AhiPoAcBwBD0A\nGI6gBwDD5RT0+/fvV0tLy4jju3btUlNTk8LhsLZu3ZrLRwAAclTq9Ac3btyod999V+Xl5WnHBwcH\ntXbtWm3fvl1lZWWaP3++brjhBl1wwQU5NxYAkD3HPfqqqiqtW7duxPFDhw6pqqpKgUBAkydPVn19\nvbq7u3NqJADAOcdB39jYqLPOOmvE8UQioYqKitTr8vJy9f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wHEEPAIYj6AHAJYV6iAxbIACACwr5EBl69ADggkI+\nRIagBwAXFPIhMgQ9ALigkA+RIegBwAWFfIgMk7EA4IJCPkSGoAcAlxTqITIM3SBnhaoFBuAMPXrk\npJC1wACcoUePnBSyFhiAMwQ9clLIWmAAzhD0yEkha4EBOEPQIyeFrAUG4AyTschJIWuBAThD0CNn\nhaoFBuAMQzcAYDiCHgAMR9ADgOEIegAwHEEPuIy9gjDRqLoBXMReQSgEevSAi9grCIVA0AMuYq8g\nFAJBD7iIvYJQCAQ94CL
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x10bdaae48>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"x = np.linspace(0, 10, 30)\n",
|
|||
|
"y = np.sin(x)\n",
|
|||
|
"\n",
|
|||
|
"plt.plot(x, y, 'o', color='black');"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"The third argument in the function call is a character that represents the type of symbol used for the plotting. Just as you can specify options such as ``'-'``, ``'--'`` to control the line style, the marker style has its own set of short string codes. The full list of available symbols can be seen in the documentation of ``plt.plot``, or in Matplotlib's online documentation. Most of the possibilities are fairly intuitive, and we'll show a number of the more common ones here:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 3,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD/CAYAAADllv3BAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlUFGe6P/BvASIgKDpHZ4JxQRLGCTJGMMEljKISnaBG\nwE5wQaMT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dHbFhwwZej4mmRFfY7Xrb\n4V9L/qU8aWgahhBxMdRv1cbYj10sRFfYgdbiTtMvhIiToX6rNsZ+7GIhyqtidMEYQ1hYGAzQrJKQ\nHk3xW/U/l/xT0IsbxNiPXSxMprBnZGQgJSUFmZmZQkchxOQpfqsWqqiLtR/7zz//DF9fXzx48EDr\n5/LJJPqxM8Ywfvx45ObmwsPDA5cuXVL7jyLWS/iEytXVVQ58Zdq4fDke3bzZbruVszPCUlO12pcY\n//0ok+bEmEuMmXStnaKcY9dWRkYGioqKAABFRUXIzMyEv7+/wKmMh6Gucnh08yaiL1xotz2a91ci\npGczyqmYtvPpjDEkJSVBJpMBAGQyGRITE2muXQsdXeVACDFeRlnY286ntx2tKyhG7UQziqscepn1\nonsHCDEBRjcVoxihS6VSJCYmYty4cRg7dqzKnDpjDN999x1Nx2iI7h0gxLSoLeyMMURHR6OkpASW\nlpaIj4/HkCFDlI+fPHkS+/fvh7m5Ofz8/DBv3jy9Bn52Pj0kJATbt2/X62v2BHTvACGmQ21hP3v2\nLBobG5Geno7CwkIkJCQgJSVF+fjmzZvxv//7v7CysoKPjw9mzpwJOzv9jPg6m0/38/PT6dIkYlhW\nzs4dflBq5exs6CiEmDS
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x10bf7e470>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"rng = np.random.RandomState(0)\n",
|
|||
|
"for marker in ['o', '.', ',', 'x', '+', 'v', '^', '<', '>', 's', 'd']:\n",
|
|||
|
" plt.plot(rng.rand(5), rng.rand(5), marker,\n",
|
|||
|
" label=\"marker='{0}'\".format(marker))\n",
|
|||
|
"plt.legend(numpoints=1)\n",
|
|||
|
"plt.xlim(0, 1.8);"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"For even more possibilities, these character codes can be used together with line and color codes to plot points along with a line connecting them:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 4,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtcVOW6B/DfcBUZFE28VjjifWumeEMCGXUUuQgkKjgD\nlp6y2qmZHT1ak+nk9tLJTrX1aLl3KqCIN25KOgaiucUL3sp7Mt7AwhQVUBCYdf7owHbiPrd3rTXP\n9/PpD9Ywa/1YDY+LZ73vuyQcx3EghBAiWnasAxBCCLEsKvSEECJyVOgJIUTkqNATQojIUaEnhBCR\no0JPCCEiZ1KhP3v2LGJiYmptz8zMRGRkJKKiorB9+3ZTDkEIIcREDsa+ccOGDUhJSYGrq6vB9srK\nSqxYsQK7du2Cs7MzoqOjMXr0aLRt29bksIQQQprP6Ct6T09PrFmzptb2a9euwdPTE1KpFI6OjvD2\n9saJEydMCkkIIcR4Rhd6hUIBe3v7WttLSkrg5uZW87WrqyuKi4uNPQwhhBATmf1mrFQqRUlJSc3X\npaWlaNWqlbkPQwghpImM7tFX+/NSOV5eXrhx4wYePXqEFi1a4MSJE5gxY0ad783NzTX18IQQYpO8\nvb2b/L0mF3qJRAIASE9Px5MnTzBp0iQsXLgQ06dPB8dxmDRpEtq3b2+WsCypVCokJCTU2u7o6Igu\nXbrA3d0dbdq0gbu7O9zd3aHVanH79u1a3y+Xy5GZmVlre0FBATp37myR7EJD5+LfxHQudDod1Go1\n8vPz0aVLF2g0GrRt2xZ79uzB7t27odVq8fLLLyMiIgJZWVlISUmptQ+lUon4+HgG6fmluRfJJhX6\nLl26IDExEQAQEhJSsz0gIAABAQ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metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"plt.plot(x, y, '-ok');"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Additional keyword arguments to ``plt.plot`` specify a wide range of properties of the lines and markers:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 5,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD6CAYAAACvZ4z8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtQVFeeB/Bv07xpQR4qSpS2UUBQIICvJBqMC9HBMcmo\nG0zUZLV2S6dqNyZT2dRs7a6T2ppyZrcyjz+CG6bjOAmZaRPjBIqsioqlUUGxiSCg7QPSqLSG1qgN\nNtCv/YPpK7ebR3fT3ff1+1Slyntpug83lx/nnvM7vyNzOBwOEEIIEa0QrhtACCEksCjQE0KIyFGg\nJ4QQkaNATwghIkeBnhBCRI4CPSGEiFwolx+u1Wq5/HhCCBGsgoICj1/LaaAHvGusmHV3d2PGjBlc\nN4MX6Fo8QdfiCboWT3jbSaahG0IIETkK9IQQInIU6AkhROQo0BNCiMhRoCeEEJGjQE8IISJHgZ4Q\nQkSOAj0hhLcsFgssFgvXzRA8zhdMiZ3zJg0LC+O4JYQIi8FgwMGDBwEA69at47g1wkaB3kveBG7X\nGzU5OTmgbSNEDBwOB+rr63H8+HHY7XYAgFqtRmFhIaZPnw6ZTMZxC4WHAr0XPA3co92oK1euxJIl\nS+hGJWQUJpMJX331FTo6OgAAhYWFcDgc0Gq1OHfuHHp6evDyyy9j0qRJHLdUWCjQe8CbwD3WjVpb\nW4vr16/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9+jTy8vIQGxsrqckkwg/Op0mu57g85Vzo9f333wOQ\nbrVYSfTor1+/jhs3brDOFRcXQy6Xc9QizxUVFbGWkFssFhw7dgwGg4G2HiRBZTabWRObYwn0HJcn\n+LjQiyui79Hb7XYcPXq
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x10e7a6208>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"plt.plot(x, y, '-p', color='gray',\n",
|
|||
|
" markersize=15, linewidth=4,\n",
|
|||
|
" markerfacecolor='white',\n",
|
|||
|
" markeredgecolor='gray',\n",
|
|||
|
" markeredgewidth=2)\n",
|
|||
|
"plt.ylim(-1.2, 1.2);"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"This type of flexibility in the ``plt.plot`` function allows for a wide variety of possible visualization options.\n",
|
|||
|
"For a full description of the options available, refer to the ``plt.plot`` documentation."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Scatter Plots with ``plt.scatter``\n",
|
|||
|
"\n",
|
|||
|
"A second, more powerful method of creating scatter plots is the ``plt.scatter`` function, which can be used very similarly to the ``plt.plot`` function:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 6,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGSZJREFUeJzt3W9QVOfd//EPyfLHslAjwQc4dnGc0sQJ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eIcaxYQKYIeiHOsWUCkCHogznGBH5FijB6w\nAC7wIxIEPWARXOBHuBi6AQCbI+gBwOYIegCwOYIeAGyOoAdgKez5EzqCHoBlJMJNfWKBoAdgCYly\nU59YIOgBWAJ7/oSPoAdgCez5Ez6CHjHFhTNEC3v+hI8tEBAz3CwD0caeP+EJK+gNw9DWrVt1/vx5\npaSkqKamRtOnTw+2Hz9+XHV1dXI4HFqyZInKy8ujVjCsgZtlIFbY8yd0YQ3dHDt2TH19fdq3b582\nbdqk2traYFsgEND27dvV2NioPXv2aP/+/bp69WrUCo4XPp9PLS0tDEmMggtnQPwIK+g9Ho/mzp0r\nSZo9e7bOnj0bbLtw4YJcLpecTqeSk5NVWFio5ubm6FQbJwbn8lZU/BdzeUfBhTMgfoQV9H6/XxkZ\nGcHHDodDAwMDI7alp6erq6srwjLjx9Ahia6uU8zlHQUXzoD4EdYYvdPpVHd3d/DxwMCAbrvttmCb\n3+8PtnV3dyszM3PUz/J6veGUYJqWlhY5HC4NHZJwOL6m5uZmzZkzx8zSQtbV1RXT73/+/Ln64IN3\ndfnyZU2fPl1ZWVlRPV6s648lK9cuUb/VhBX0BQUFOnHihBYsWKCWlhbl5eUF22bOnKn29nZdu3ZN\naWlpam5ultvtHvWzcnJ
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x10e8a18d0>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"plt.scatter(x, y, marker='o');"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"The primary difference of ``plt.scatter`` from ``plt.plot`` is that it can be used to create scatter plots where the properties of each individual point (size, face color, edge color, etc.) can be individually controlled or mapped to data.\n",
|
|||
|
"\n",
|
|||
|
"Let's show this by creating a random scatter plot with points of many colors and sizes.\n",
|
|||
|
"In order to better see the overlapping results, we'll also use the ``alpha`` keyword to adjust the transparency level:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVcAAAD/CAYAAABFCZUvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXeMZGl97/0551Q6lXNVV+fu6ZmevDObF3YJy8KCfbkv\ntsDYQkYykuU/sBC2ZWFj2UbIQrL8IoQEknX5wxLimvdeJxZjwLtsYvPknZlO0zlUzjmdc94/eqZn\nerun8+z2zJ6PVLvqquc85+ma6m89zy8KmqZp6Ojo6OjsKeJ7vQAdHR2dexFdXHV0dHTuALq46ujo\n6NwBdHHV0dHRuQPo4qqjo6NzB9DFVUdHR+cOYNjphaqq8ld/9VfMzMwgiiLf+MY3OHDgwF6uTUdH\nR+euZcc71+effx5BEPjnf/5nvvKVr/Dtb397L9elo6Ojc1ez453rxz72MT760Y8CsLS0hMvl2rNF\n6ejo6Nzt7FhcAURR5Gtf+xrPPfcc3/3ud/dqTTo6Ojp3PcJepL9mMhk++9nP8l//9V9YLJa9WJeO\njo7OXc2Od64/+clPSCQS/OEf/iFmsxlRFBHF1Sbcc+fO7XqBOjo67x/uv//+HV97+dKrNNtb29yZ\nTCaOHz++43tthR2L68c//nH+4i/+gi984Qu0222+/vWvYzKZ1ozbzZv1bhONRolEIu/1MraFvuY7\nz922Xrg717zbzVizbeHkwZe2NPbSxId2da+tsGNxlWWZ73znO3u5Fh0dHZ1dsZ+K/O3KoaWjo6Oz\nn1Da01sc+eE7uQxAF1cdHZ17CUPfe72CFXRx1dHRuWdQ3+sF3IIurjo6OvcMGrrNVUdHR2fP2Uf+\nLF1cdXR07h30nauOjo7OHUC3uero6OjcARp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J03RU9DI5FIMjZyDUmUoW2mUqsR6R7CaDbRbDRYmp5mYWwKQbQg\niiIW2YrFIpPPQXw+SrvVxO124nLZcTqctFotZuajhBsNQqHQ2gUJAg6HE4fDSblS5K3XztM31M3A\nQD82m51Uana3b6vOPYa2jwKgdHG9C5idneXqyK84eFAm0nl7g73BINHZFaCzK8DSYopfv/J/OXb0\nY/T19W16D0VRePm1l0lqWYYfXO28UlSF0ZFREvECfm8HxWKRRCaL2xtAlCQATGYzncMDzI6ME59Y\nIhgZRBIl0qkkpWwJv7sDQRSpVAosLMzR29uHLFsxyVamZucpV4oEAyFkWV43wsBuc2K1WFm4FqVW\nqXLg4BCtVnv7b+ZdSKvVolQqoaoqRqMRh8OxZ87Be418c2HzQYCNB+/wSnRx3ffMzs4yOvZLHnq4\nA6vVsuXrOrsCuD11zp75BYLwyU0962cvnCOhZjhwbGiVOUFRFd6+dJlivkVnuJdqrcpSPL1KWG8g\nCAK+SIh4tEg0OYdFslPJlnHavStz2m1uVEVjfOIqNhf4/DJWn0ayHKVtiKOmTDjkEF53AKtsWzW/\nKBnoCHYRj8VotkYIee7dj2+j0WBubpb5uSvU61nsNhFRgnYLKjVwuyL09R8jEokgvePf4f2M3bi1\nCJJ3I0p6R5/OdrvNX/7lX7K0tESr1eKP/uiP+OhHP7rXa3vfUywWuXL1uW0L6w1sNgsPPBjhrTef\nw+v93KpyarcSj8cZj19j+OEjq4RVQ+PqlVGK+RahYAeqqjI3v4TN7lojrDcwGk1YHTKlVp58rEAk\n2Lsyp6ZplEppaq0c/qCFplLC7XNjs1lpNuworRodYSfFYobFVByz6KO7ox9RuuVjKgiEAx1MzY5h\nwbrt92S/c6PIzdjoy4QCCved8OJ09q76d1FVlVSqwNzsLxkb9XD6/g9vKwb5Xmar0QLvhttrR2eL\nZ555Bo/Hw49+9CP+1//
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x10e8fce10>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"rng = np.random.RandomState(0)\n",
|
|||
|
"x = rng.randn(100)\n",
|
|||
|
"y = rng.randn(100)\n",
|
|||
|
"colors = rng.rand(100)\n",
|
|||
|
"sizes = 1000 * rng.rand(100)\n",
|
|||
|
"\n",
|
|||
|
"plt.scatter(x, y, c=colors, s=sizes, alpha=0.3,\n",
|
|||
|
" cmap='viridis')\n",
|
|||
|
"plt.colorbar(); # show color scale"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Notice that the color argument is automatically mapped to a color scale (shown here by the ``colorbar()`` command), and that the size argument is given in pixels.\n",
|
|||
|
"In this way, the color and size of points can be used to convey information in the visualization, in order to visualize multidimensional data.\n",
|
|||
|
"\n",
|
|||
|
"For example, we might use the Iris data from Scikit-Learn, where each sample is one of three types of flowers that has had the size of its petals and sepals carefully measured:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 8,
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAENCAYAAAAPAhLDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmQXfdZ8PnvWe6+770v6kWbtdiynTg2jrBDwvvGeAJY\n88ZgZxg8YSpFzfDierewJaR4eRMKKIqiWAI1pAxFSCXYw2ASkjgiebNgW5atvVtL78vtu+/rOfec\n+aOla7dbUndLanVL/n2qXCXfe8+5z+2+fZ7z256fZJqmiSAIgvCeJ291AIIgCML2IBKCIAiCAIiE\nIAiCIFwmEoIgCIIAiIQgCIIgXCYSgiAIggCAupkn/5mf+RncbjcAPT09/O7v/m77uaNH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+eu\n+7DZlr+7pmkyOXmeZm2Wzg4PXm/niv08Wq0W2WySiYtzdHYfuCsnw4gxBGHdotEokd4gc/H59mOG\nYTK9MMXB9x3YwsgEYbkszoXzb9HdAR0doWuWZVEUha6uMB0RnQvnT7Y3iZqevoTRnGV0pAOfz7Nq\ncydFUYhEguwcCbG0cIJsNrvpn+l2EwnhLlav15mfn2d2dpZqtXpLzvnRj/17JJ/O2cnTXJw+z5np\nk+y4t48H3/fgLTk/gKZpGIZxy84nvDckk0m8rgqhkH9dr49EAjhtRVKpFOVymXJhmh07Otas72Wz\nWRkeCjI7c+au+56KLqO71MzMDN96+TvEp5YAiWhPiMc/+uOMjIzc1Hn9fj+f+D+eZX5+nlqtRigU\nIhwO35KYi8Ui42fGqRQ
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.figure.Figure at 0x1107c79b0>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"from sklearn.datasets import load_iris\n",
|
|||
|
"iris = load_iris()\n",
|
|||
|
"features = iris.data.T\n",
|
|||
|
"\n",
|
|||
|
"plt.scatter(features[0], features[1], alpha=0.2,\n",
|
|||
|
" s=100*features[3], c=iris.target, cmap='viridis')\n",
|
|||
|
"plt.xlabel(iris.feature_names[0])\n",
|
|||
|
"plt.ylabel(iris.feature_names[1]);"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"We can see that this scatter plot has given us the ability to simultaneously explore four different dimensions of the data:\n",
|
|||
|
"the (x, y) location of each point corresponds to the sepal length and width, the size of the point is related to the petal width, and the color is related to the particular species of flower.\n",
|
|||
|
"Multicolor and multifeature scatter plots like this can be useful for both exploration and presentation of data."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## ``plot`` Versus ``scatter``: A Note on Efficiency\n",
|
|||
|
"\n",
|
|||
|
"Aside from the different features available in ``plt.plot`` and ``plt.scatter``, why might you choose to use one over the other? While it doesn't matter as much for small amounts of data, as datasets get larger than a few thousand points, ``plt.plot`` can be noticeably more efficient than ``plt.scatter``.\n",
|
|||
|
"The reason is that ``plt.scatter`` has the capability to render a different size and/or color for each point, so the renderer must do the extra work of constructing each point individually.\n",
|
|||
|
"In ``plt.plot``, on the other hand, the points are always essentially clones of each other, so the work of determining the appearance of the points is done only once for the entire set of data.\n",
|
|||
|
"For large datasets, the difference between these two can lead to vastly different performance, and for this reason, ``plt.plot`` should be preferred over ``plt.scatter`` for large datasets."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"<!--NAVIGATION-->\n",
|
|||
|
"< [Simple Line Plots](04.01-Simple-Line-Plots.ipynb) | [Contents](Index.ipynb) | [Visualizing Errors](04.03-Errorbars.ipynb) >"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"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
|
|||
|
}
|