data-science-ipython-notebooks/matplotlib/04.01-Simple-Line-Plots.ipynb

645 lines
289 KiB
Python
Raw Normal View History

{
"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",
"< [Visualization with Matplotlib](04.00-Introduction-To-Matplotlib.ipynb) | [Contents](Index.ipynb) | [Simple Scatter Plots](04.02-Simple-Scatter-Plots.ipynb) >"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simple Line Plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Perhaps the simplest of all plots is the visualization of a single function $y = f(x)$.\n",
"Here we will take a first look at creating a simple plot of this type.\n",
"As with all the following sections, we'll start by setting up the notebook for plotting and importing the packages 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": [
"For all Matplotlib plots, we start by creating a figure and an axes.\n",
"In their simplest form, a figure and axes can be created as follows:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAAN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4O\npq/5fD5Fo1H5fD5J0oMHD7Rw4cI8jQoAmAnXsI+Pj6u4uDh97PV6lUqlJEkej0clJSWSpJMnT2py\nclLr1q3L06gAgJlw/Y7d7/drYmIifZxKpTRvXubPA8dxdOTIEV2/fl0dHR3/+DqJROIZR7VhbGyM\nXTzCLjLYRQa7eHauYa+pqVFvb68aGho0MDCgqqqqadcPHDigoqIiHT9+POvrlJaWPtukRiQSCXbx\nCLvIYBcZ7CJjZGRkVs9zDXsgEFBfX59CoZAkKRKJKBaLaXJyUmvWrNHp06dVW1urcDgsj8ejpqYm\nbdiwYVbDAACenWvYPR6P2trapp2rrKxM//rXX3/N/VQAgFnjBiUAMIawA4AxhB0AjCHsAGAMYQcA\nYwg7ABhD2AHAGMIOAMYQdgAwhrADgDGEHQCMIewAYAxhBwBjCDsAGEPYAcAYwg4AxhB2ADCGsAOA\nMYQdAIwh7ABgDGEHAGMIOwAYQ9gBwBjCDgDGEHYAMIawA4AxhB0AjCHsAGAMYQcAYwg7ABhD2AHA\nGMIOAMYQdgAwhrADgDGEHQCMIewAYIxr2B3H0cGDBxUKhdTU1KQbN25Mu97T06OtW7cqFAqpq6sr\nb4MCAGbGNezd3d1KJpOKRqNqbm5WJBJJX3vw4IEOHTqkzz//XCdPntTXX3+tP//8M68DAwCycw17\nPB5XXV2dJKm6ulqDg4Ppa9euXVNFRYX8fr8WLFig2tpa9ff3529aAIAr17CPj4+ruLg4fez1epVK\npZ54bcmSJRobG8vDmAC
"text/plain": [
"<matplotlib.figure.Figure at 0x102e12390>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = plt.axes()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Matplotlib, the *figure* (an instance of the class ``plt.Figure``) can be thought of as a single container that contains all the objects representing axes, graphics, text, and labels.\n",
"The *axes* (an instance of the class ``plt.Axes``) is what we see above: a bounding box with ticks and labels, which will eventually contain the plot elements that make up our visualization.\n",
"Throughout this book, we'll commonly use the variable name ``fig`` to refer to a figure instance, and ``ax`` to refer to an axes instance or group of axes instances.\n",
"\n",
"Once we have created an axes, we can use the ``ax.plot`` function to plot some data. Let's start with a simple sinusoid:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8TWf+B/BPIiQk1FJbtEJTUR1LJcqoJiixJgiJJiHR\n0o3pypQuM4zWOjO/1rRlqqjYKrXEFnsIbY0WUZTSUVVUaIsiScl6f398J9ZEcu899z5n+bxfL69p\nJPeczxzH13Oe8yweNpvNBiIiMi1P1QGIiMi1WOiJiEyOhZ6IyORY6ImITI6FnojI5FjoiYhMzqlC\nv3//fiQkJNz2+1u3bkV0dDRiY2OxdOlSZ05BRERO8nL0g7Nnz8aqVavg6+t70+8XFBRgypQpSElJ\ngbe3N+Li4tClSxfUrFnT6bBERGQ/h1v0AQEBmD59+m2/f+zYMQQEBMDPzw8VK1ZESEgIdu/e7VRI\nIiJynMOFPjw8HBUqVLjt97Ozs1G1atVrX/v6+iIrK8vR0xARkZM0fxnr5+eH7Ozsa1/n5OSgWrVq\nWp+GiIjKyeE++mK3LpUTGBiIEydO4PLly/Dx8cHu3bsxbNiwEj+bkZHh7OmJiCwpJCSk3D/rdKH3\n8PAAAKSmpuLKlSuIiYnB66+/jqFDh8JmsyEmJgZ16tTRJKxqRUXAv/4FTJwIDB8OvPwyUKtW6T9f\nUAAsWwa88QbQti3wwQfA3XeX/LOZmZnw9/d3TXCD4bW4zqzX4quvgGHDgIYNgbfeAtq0ufPP798P\nvPbaFRw7VhmzZgEdO7onp17Z3Ui2KbRnzx6Vp7fLxYs2W+/eNtsjj9hs//2vfZ/NybHZRo2y2Ro2\ntNm++qrknzl9+rTzIU2C1+I6s12LoiKb7Y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u9Glg0ybZEd5M7rkH6NgR+OQT1UnIKj74QFrzRpsgVZZnn5VW\nvdmZutB/9JH0w+lp1xutPPec7EDFoZbkat9/L2tEPf646iTai4iQPZoPHlSdxLVMW+gLCmTVx+ee\nU53ENcLDgUuXZEwzkSt9+CHw5JPGWO3VXl5ewLBh5m/Vm7bQb9wINGgAtGypOolreHrKY+e//606\nCZlZXh6wYIEMRzSrp56SbtDff1edxHVMW+hnzzb3zQlIK2vFCuC331QnIbNas0bWcW/SRHUS12nY\nEHjkEeDTT1UncR1TFvqzZ2WVythY1Ulcq3ZtoFcvYOFC1UnIrGbPlq4NszP7S1lTFvr582VlvapV\nVSdxvaFDrb0XJrnOyZOy7eaAAaqTuF7PnkBmJnDggOokrmG6Qm+zyUtYs3fbFHvsMeD8eZktS6Sl\npCR5KjbyujblVaGCLNQ2b57qJK5hukL/xRfyh9a+veok7uHpKTcoW/WkpcJCazWYAPl7tGgRkJ+v\nOon2TFfoi/sUzTax406eeEJGDVh1h3vS3pYtQK1aQOvWqpO4T1CQLHS2caPqJNozVaG/fBlYtQpI\nSFCdxL0CA2VjkrVrVSchs0hKkvc/VjNkiPx/NxtTFfqUFFkawAyr69nrySfZfUPayMoC1q0z/6i1\nkgwcCKSlyXsvMzFVoV+4EBg8WHUKNaKjgc8/l6GlRM5ISQHCwoC771adxP2qV5cROMnJqpNoyzSF\n/qefgL17gchI1UnU8PMD+vXjQmfkPCs3mADpvjHb6BvTFPrFi2UvSDOux1Fegwax0JNzTp+WvVSt\n2mACZB2p06eBb79VnUQ7pin0CxZY7yXsrTp3lkkfZtjqjdRYvFgmG1ph7HxpKlSQJ5r581Un0Y4p\nCv2BA7KSY2io6iRqVaggL9DYqidHLVzIBhMgW3YmJ8vOWmbgUKG32WwYN24cYmNjkZiYiFOnTt30\n/aSkJERERCAxMRGJiYn
"text/plain": [
"<matplotlib.figure.Figure at 0x107527f98>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = plt.axes()\n",
"\n",
"x = np.linspace(0, 10, 1000)\n",
"ax.plot(x, np.sin(x));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternatively, we can use the pylab interface and let the figure and axes be created for us in the background\n",
"(see [Two Interfaces for the Price of One](04.00-Introduction-To-Matplotlib.ipynb#Two-Interfaces-for-the-Price-of-One) for a discussion of these two interfaces):"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8TWf+B/BPIiQk1FJbtEJTUR1LJcqoJiixJgiJJiHR\n0o3pypQuM4zWOjO/1rRlqqjYKrXEFnsIbY0WUZTSUVVUaIsiScl6f398J9ZEcu899z5n+bxfL69p\nJPeczxzH13Oe8yweNpvNBiIiMi1P1QGIiMi1WOiJiEyOhZ6IyORY6ImITI6FnojI5FjoiYhMzqlC\nv3//fiQkJNz2+1u3bkV0dDRiY2OxdOlSZ05BRERO8nL0g7Nnz8aqVavg6+t70+8XFBRgypQpSElJ\ngbe3N+Li4tClSxfUrFnT6bBERGQ/h1v0AQEBmD59+m2/f+zYMQQEBMDPzw8VK1ZESEgIdu/e7VRI\nIiJynMOFPjw8HBUqVLjt97Ozs1G1atVrX/v6+iIrK8vR0xARkZM0fxnr5+eH7Ozsa1/n5OSgWrVq\nWp+GiIjKyeE++mK3LpUTGBiIEydO4PLly/Dx8cHu3bsxbNiwEj+bkZHh7OmJiCwpJCSk3D/rdKH3\n8PAAAKSmpuLKlSuIiYnB66+/jqFDh8JmsyEmJgZ16tTRJKxqRUXAv/4FTJwIDB8OvPwyUKtW6T9f\nUAAsWwa88QbQti3wwQfA3XeX/LOZmZnw9/d3TXCD4bW4zqzX4quvgGHDgIYNgbfeAtq0ufPP798P\nvPbaFRw7VhmzZgEd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ERERCAxMRGJiYn
"text/plain": [
"<matplotlib.figure.Figure at 0x107066518>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we want to create a single figure with multiple lines, we can simply call the ``plot`` function multiple times:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXdYVEfbxu+lVxtgwYKKNBULKMbeAEEpIqCAgi1FTbfE\n+CbRaIqaaN40TewG7CBKsWPXWAC7UizYQFFsFKWf74/58LUhsHt255xhftfllbC7Z86dzeF25pl5\nnkchCIIADofD4TCLFm0BHA6Hw1Ev3Og5HA6HcbjRczgcDuNwo+dwOBzG4UbP4XA4jMONnsPhcBhH\nJaM/e/YsQkNDX3t93759CAgIQFBQECIjI1W5BYfD4XBUREfZC5cvX46YmBgYGxu/9HppaSnmzZuH\n6Oho6OvrIzg4GAMHDkSDBg1UFsvhcDicmqP0jN7KygqLFi167fWrV6/CysoKJiYm0NXVhbOzMxIT\nE1USyeFwOBzlUdro3dzcoK2t/drr+fn5MDU1ff6zsbEx8vLylL0Nh8PhcFRE9M1YExMT5OfnP/+5\noKAAderUEfs2HA6Hw6kmSsfoK3i1VI61tTVu3LiB3NxcGBgYIDExEePHj3/jtcnJyarensPhcGol\nzs7O1f+woAK3b98WRowYIQiCIMTFxQmbNm0SBEEQ9u/fL/j7+wvDhg0T1q1bV+n1SUlJL/2cej9V\nCNwUKDT/pbmQcDVBFWlqoaxMEH75RRDMzATh668FISfn7Z8vKRGE9esFoVUrQRgxQhDu36/8s5mZ\nmeKKlTH8u/gfmZmZQn5RvvB+7PtCkwVNhGXJy4TCksK3XpNXlCfMPTxXMJtvJnyz7xuhpKxEQ2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c0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"plt.plot(x, np.cos(x));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"That's all there is to plotting simple functions in Matplotlib!\n",
"We'll now dive into some more details about how to control the appearance of the axes and lines."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adjusting the Plot: Line Colors and Styles"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The first adjustment you might wish to make to a plot is to control the line colors and styles.\n",
"The ``plt.plot()`` function takes additional arguments that can be used to specify these.\n",
"To adjust the color, you can use the ``color`` keyword, which accepts a string argument representing virtually any imaginable color.\n",
"The color can be specified in a variety of ways:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd4VGXWwH8z6Y1AEhJ6KNI7SG8KIoIUEUWxoFh23V11\nd3U/y7rr6hZXUde+lmVXVlERpBdBBCmhh05CJwkhvZdJnZnz/XEZSMJkyp17Z3DN73m+59vced87\nx8t7z5z3vKcYRERoookmmmjifxajrwVoookmmmhCX5oUfRNNNNHE/zhNir6JJppo4n+cJkXfRBNN\nNPE/TpOib6KJJpr4H6dJ0TfRRBNN/I/jkaI/cuQI999//1XXt2zZwh133MHdd9/N0qVLPfmKJppo\nookmPMRf7cQFCxawatUqwsLC6l03m828+uqrLF++nKCgIObMmcOECROIioryWNgmmmiiiSbcR7VF\nHx8fzwcffHDV9XPnzhEfH094eDgBAQEMHjyY/fv3eyRkE0000UQT6lGt6CdOnIifn99V18vLy4mI\niLj8d1hYGGVlZWq/pokmmmiiCQ/R/DA2PDyc8vLyy3+bTCaaNWum9dc00UQTTTThIqp99DYalsrp\n0qULaWlplJaWEhwczP79+3n44Yft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v7+9NCn0veffTVLyHCV33z7G7ln2T0iIlJbWyt7\n9uyR7Oxsr8pgMplk27Ztl/31UrxK5OIvRazaRoE4JfcfIrlvKP+7zCRy60MiO/Z5V4aUdDHfcLcS\nxikiO+VNj3aqarCKVZb
"text/plain": [
"<matplotlib.figure.Figure at 0x1077b3a90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x - 0), color='blue') # specify color by name\n",
"plt.plot(x, np.sin(x - 1), color='g') # short color code (rgbcmyk)\n",
"plt.plot(x, np.sin(x - 2), color='0.75') # Grayscale between 0 and 1\n",
"plt.plot(x, np.sin(x - 3), color='#FFDD44') # Hex code (RRGGBB from 00 to FF)\n",
"plt.plot(x, np.sin(x - 4), color=(1.0,0.2,0.3)) # RGB tuple, values 0 to 1\n",
"plt.plot(x, np.sin(x - 5), color='chartreuse'); # all HTML color names supported"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If no color is specified, Matplotlib will automatically cycle through a set of default colors for multiple lines.\n",
"\n",
"Similarly, the line style can be adjusted using the ``linestyle`` keyword:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD/CAYAAADsfV27AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd4VFX6xz8zmfQeWgiBEEpEWgSSACpSfqI0C6BIj33t\nuurawLWg4tp3XXARECZ0KdIEURFRipQAgdARAiHJDCSkTHpm5v7+uDPpCITMmQmcz/PkMffemTmv\nl8l3zpzzft9XoyiKgkQikUgaLFpnByCRSCSSq0MKuUQikTRwpJBLJBJJA0cKuUQikTRwpJBLJBJJ\nA0cKuUQikTRwLkvIk5KSmDBhAgCHDx/mgQceYNy4cUyaNMmhwUkkEonk0lxSyGfNmsXkyZMpKysD\nYNq0aTzzzDMsWLCAkpISfv31V0fHKJFIJJK/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GMX8s6dxcfk5eVFeHg4W7dupV07\ncXnWimIhO3sjBoOerKzvCQ7uT3j4CzRqNFRYDADFZ4sxzjdiTDBiLbUSOjGU7ju74x3pfVWve1lL\nK3UhMTHxir8eXKvIWWgF8l5U4Oh78fbbEBQEL7zgsCH+knXr1tG2bVtuuOGGSz7W0ffCai1h//6h\nNG58D02bjsHDQ1DBF8BSYCFzZSYGvQHTbhNN7mtCaHwoATcH1DpBrot2SkOQRHKNsH8/fP99hUX+\njTdwyvq3naysLJo0aeK8ACqh1Xpy000/CxtPsSrk/p6LQW8g87tMAnoH0PyR5nRe1Rk37/rPfJFC\nLpE0UMxm2LkTbr5ZPW7
"text/plain": [
"<matplotlib.figure.Figure at 0x1079d9160>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, x + 0, linestyle='solid')\n",
"plt.plot(x, x + 1, linestyle='dashed')\n",
"plt.plot(x, x + 2, linestyle='dashdot')\n",
"plt.plot(x, x + 3, linestyle='dotted');\n",
"\n",
"# For short, you can use the following codes:\n",
"plt.plot(x, x + 4, linestyle='-') # solid\n",
"plt.plot(x, x + 5, linestyle='--') # dashed\n",
"plt.plot(x, x + 6, linestyle='-.') # dashdot\n",
"plt.plot(x, x + 7, linestyle=':'); # dotted"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you would like to be extremely terse, these ``linestyle`` and ``color`` codes can be combined into a single non-keyword argument to the ``plt.plot()`` function:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD/CAYAAADsfV27AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtYVNXeB/DvcL8IyEVNxBTxgrc0UfNkppWWZr1pmpni\npezyaiaVmaamdgOtk5qEpZInwwxT6VUzq+PRFD0qSoHiBS9oKCAoyB1hLvv9Y4uDSgHjzFoz8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z9c5yDt16oRDhw6hV69e2LNnD/r06fOXP+vv71/nguqjzMxMnovreC6MpJ2LNWuAS5fU\njYwBYMYM8TUAOHfuHGJiYhAREYF7771X+Lk4UVICZzs7tJFw1V+pXFeONclrsGjfIgR4BmDJ40sA\nE/7sqHOQz5w5E++++y60Wi2CgoIwePDguo9KRGLl5ABNm6qvH30UqNJII0tgYCD27t0LQOzf3g8X\nFiIiPR17CwqwskMHKUFeXFGMlYkr8en+T9H9ru5YM2wNHrj7AQDqUgN1Vasgb9GiBWJjYwEArVu3\nRkxMTJ0HIiJJrlwBBg5Un0axt1cXthJszZo18Pf3x6BBg4SPDajz8Lvz8xGeno4TpaV4S1IXZl5Z\nHiIPRiLqUBQeCnwI28ZsQ/e7ut/x97IhiKg+2rED6NIFuOsuwM/PGOKSdOjQAT4+PtLGz9PpMO3M\nGYQFBGBcs2ZwshPb1J5VlIXF+xdjddJqDOswDHtf2Iv2vu3N9v0McqL6KCkJ8PZWgxwQGuIFBQXw\numUTib+7lyaCr6Mjknv
"text/plain": [
"<matplotlib.figure.Figure at 0x1077be9e8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, x + 0, '-g') # solid green\n",
"plt.plot(x, x + 1, '--c') # dashed cyan\n",
"plt.plot(x, x + 2, '-.k') # dashdot black\n",
"plt.plot(x, x + 3, ':r'); # dotted red"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These single-character color codes reflect the standard abbreviations in the RGB (Red/Green/Blue) and CMYK (Cyan/Magenta/Yellow/blacK) color systems, commonly used for digital color graphics.\n",
"\n",
"There are many other keyword arguments that can be used to fine-tune the appearance of the plot; for more details, I'd suggest viewing the docstring of the ``plt.plot()`` function using IPython's help tools (See [Help and Documentation in IPython](01.01-Help-And-Documentation.ipynb))."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adjusting the Plot: Axes Limits\n",
"\n",
"Matplotlib does a decent job of choosing default axes limits for your plot, but sometimes it's nice to have finer control.\n",
"The most basic way to adjust axis limits is to use the ``plt.xlim()`` and ``plt.ylim()`` methods:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD/CAYAAAAOoUbCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtcVGX+B/DPCAjIJc1Lha5k7ppZZoG5ZgtqRqGSVzBQ\nLoqlaakpKbldDMtQy9U2MVFUhEy8lpfdNFFDl2pVXDUpzdokdchWLWWQxIHz++MJfl5AYebMPOec\n+bxfL1/JDDPncxr4+pznPBeToigKiIjIEBrIDkBEROphUSciMhAWdSIiA2FRJyIyEBZ1IiIDYVEn\nIjIQu4r6wYMHERcXd93jmZmZiIiIQHx8POLj43H8+HF7DkNERHXkbusLMzIysGHDBvj4+Fz3XGFh\nIWbPno0OHTrYFY6IiOrH5pZ6YGAg0tLSanyusLAQ6enpGDp0KBYtWmRzOCIiqh+bi3pYWBjc3Nxq\nfK5v375ISUlBVlYWCgoKkJeXZ3NAIiKqO4fcKE1ISEDjxo3h7u6O7t274+uvv3bEYYiI6Bo296lX\nuXbpGIvFgoiICHzyySfw8vLCl19+icjIyBpfW1BQYO/hiYhcUnBwcI2P213UTSYTAGDz5s0oKytD\nVFQUJk2ahLi4OHh6euLhhx9GaGhovYM5gtlsRkBAgNOO52w8P/0y8rkBPD+13ahBbFdRb9myJXJy\ncgAAERER1Y/369cP/fr1s+etiYjIBpx8RERkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKi\nTkRkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKiTkRkICzqREQGwqJORGQgLOpERAbCok5E\nZCAs6kREBsKiTkRkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKiTkRkICzqREQGwqJORGQg\nLOpERAbCok5EZCB2FfWDBw8iLi7uusd37NiByMhIREdHY82aNfYcgoiI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nYnSJGmtMO9qECcCXX4o/ROvXA7/9BsTGyk5yc506if0IZs+WnUT7WNTtcOyYmHmXlCQ7Sd14e4u+\n/5dekp2EZKuoEFPxZ8xw7OqhanrjDTGK66efZCfRNp18nNo0fbpo/TZuLDtJ3cXHi9EEXBfGta1Z\nA/j5Ab17y05Sd61bixv+3L7xxljUbfTNN8DWrWLIlZ64uwOvvipa7OSaKirE55+Sos3RWjeSnCz2\nJjh9WnYS7WJRt1FKiuh28feXnaT+hg0DTpwQ+02S61m1CmjSRCytqzctW7K1fjMs6jYoLBTdF889\nJzuJbdzdxRBHttZdj55b6VWSk4GlSzmZrjYs6jaYNUv0pet5SdvYWDEcc/du2UnImdasEcNbtbQc\nQH21agUMHSpnvXc9YFGvp6IiscnzmDGyk9jH3V3MJExNlZ2EnEVRxJDAl17Sbyu9yksviaU5zp2T\nnUR7WNTr6W9/A0aO1NeIl9rExgIHDogNhsn4cnOBS5eAvn1lJ7Ffq1ZAv37AwoWyk2gPi3o9nDkD\nZGdre0p1fXh6ihXweBnrGmbNEpum6GVc+s28+CLw3ntiAhX9P4N8vM4xf75YvD8gQHYS9Tz7rJhA\ndfKk7CTkSAUFwNGjoi/aKO67D3jwQdHQov/Hol5HpaViAwGjbQ/XpAmQkADMmyc7CTnS7NnAxIlA\nw4ayk6hryhSxOmplpewk2mFTUVcUBdOmTUN0dDTi4+Nx4sSJq57PzMxEREQE4uPjER8fj+PHj6uR\nVarMTCAkBGjXTnYS9b3wgpjQ8euvspOQI3z/PbB9O/DMM7KTqK97dzEzdtMm2Um0w92WF+Xm5qK8\nvBw5OTk4ePAgUlNTsWD
"text/plain": [
"<matplotlib.figure.Figure at 0x107ab9f28>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"\n",
"plt.xlim(-1, 11)\n",
"plt.ylim(-1.5, 1.5);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If for some reason you'd like either axis to be displayed in reverse, you can simply reverse the order of the arguments:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD6CAYAAABamQdMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlYVXX+B/D3VVCQC+U+aZMWSbYoDphZ5pqkuKQoJijg\nVlNqjiljpmluGerML7VGE1cELRCXMquZNJUUKZG00tJKHXXETMUSUETk/v74hLssd/ue5f16nnlm\n8F7PeXvm3A/nfleLzWazgYiIDKWS6gBEROR8LO5ERAbE4k5EZEAs7kREBsTiTkRkQCzuREQG5KHy\n5FlZWSpPT0SkW8HBwaW+rrS4A2UHNIvs7GzUq1dPdQxN4LW4itfiKl6Lq8rzYMxmGSIiA2JxJyIy\nIBZ3IiIDYnEnIjIgFnciIgNicSciMiAWdyIiA2JxJyIyIBZ3IiIDYnEnIjIgFnciIgNicSciMiCH\nivvGjRsRGxt7y9dWrVqF3r17IyIiAlu3bnXkNEREVEF2rwo5ffp0pKen48EHH7zptdOnTyMpKQnr\n1q1DQUEBIiMj0apVK3h6ejoUloiIysfuJ/egoCBMnjz5lq99++23CA4OhoeHB6xWKxo2bIgDBw7Y\neyoiIqqgMp/cV69ejeXLl1/3Z3FxcQgNDcXOnTtv+Xfy8vLg6+t75edq1aohNzfXwahE2lBQABw4\nAJw6BdhsQPXqQEAA4OenOhnRVWUW9/DwcISHh1fooFarFXl5eVd+zs/Ph99t7vzs7OwKHduocnNz\neS3+oMVrkZNTCevWeWP9em/s2+eBP//5MmrVKkalSsBvv1lw8KAH7rnnMrp0KUB4+Hk0bHjZKefV\n4rVQhdeiYlyyE1PTpk0xZ84cFBYW4uLFizh06BAaNWp0y/dyZxXBXWau0tK1yMkB3nwTWLoU6NoV\nmDYNaNMGqFbt+hbNoiJg165KSEnxxDPP+CIkBHjjDcDf37Hza+laqMZrcdWJEyfKfI9Th0ImJCRg\ny5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WqaNmyJfbv33/L4h4Z+Ttmz/bE/ff/5si/Q/dyc3ORnZ2tOoYm3O5a2GzAnDm1\nMW7cOWRnX1SQzP3Ke1907VoJbdvWQWzsSfj5GfOrMD8jFWNXh2pQUBDS0tLQpEkTpKWlofkNjwuH\nDx/GqFGj8OGHH6KoqAhZWVno1avXLY81YsQduO8+wMOjGurUsSeNMWRnZ6NevXqqY2jC7a5FRgZw\n8SIQGVnTcNvo3U5574t69YBOnYDPP78Lw4e7IZgC/IxcdeLEiTLfY9dHJDIyEj/99BP69euH1NRU\nvPTSSwCAhIQEbNmyBf7+/ujZsyf69OmDmJgYhIWFwd/f/5bHql4dCAsDEhLsSUJmMm+ezMo0S2Gv\nqBdflOUY2IdFAGCx2dTdCllZWQgODsbOnUBkpAxxM+sHl08lV93qWpw6BTRqBBw+LA8EZlGR+8Jm\nAxo3BpYuBVq1cnEwBfgZuaqkdpZGE6X00UeBO+4ANm5UnYS0KjER6NHDXIW9oiyWq0/vRJoo7rwp\nqTQ2m0yxf/551Um0b8AA4KOPgNOnVSch1TRR3AGgXz8gLQ343/9UJyGt2b5dmuuM2NTgbDVqyDcc\nbqJNminuVqu0uy9erDoJac2iRcBzz3EdmfIq+RZcXKw6CamkmeIOyESMZcuAy5dVJyGtOHsWWL8e\niIlRnUQ/WraUpRm++EJ1ElJJU8U9MFC2S9u8WXUS0oqVK2X8tpm20XOUxQIMGSKjZsi8NFXcAWDw\nYN6UJNiRar/+/eUbz++/q05CqmiuuEdGyq7uOTmqk5Bqu3YBublAhw6qk+hP7dpAx45ASorqJKSK\n5op7jRpAaKgsEEXmVtK
"text/plain": [
"<matplotlib.figure.Figure at 0x1079fa160>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"\n",
"plt.xlim(10, 0)\n",
"plt.ylim(1.2, -1.2);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A useful related method is ``plt.axis()`` (note here the potential confusion between *axes* with an *e*, and *axis* with an *i*).\n",
"The ``plt.axis()`` method allows you to set the ``x`` and ``y`` limits with a single call, by passing a list which specifies ``[xmin, xmax, ymin, ymax]``:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD/CAYAAAAOoUbCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtcVGX+B/DPCAjIJc1Lha5k7ppZZoG5ZgtqRqGSVzBQ\nLoqlaakpKbldDMtQy9U2MVFUhEy8lpfdNFFDl2pVXDUpzdokdchWLWWQxIHz++MJfl5AYebMPOec\n+bxfL1/JDDPncxr4+pznPBeToigKiIjIEBrIDkBEROphUSciMhAWdSIiA2FRJyIyEBZ1IiIDYVEn\nIjIQu4r6wYMHERcXd93jmZmZiIiIQHx8POLj43H8+HF7DkNERHXkbusLMzIysGHDBvj4+Fz3XGFh\nIWbPno0OHTrYFY6IiOrH5pZ6YGAg0tLSanyusLAQ6enpGDp0KBYtWmRzOCIiqh+bi3pYWBjc3Nxq\nfK5v375ISUlBVlYWCgoKkJeXZ3NAIiKqO4fcKE1ISEDjxo3h7u6O7t274+uvv3bEYYiI6Bo296lX\nuXbpGIvFgoiICHzyySfw8vLCl19+icjIyBpfW1BQYO/hiYhcUnBwcI2P213UTSYTAGDz5s0oKytD\nVFQUJk2ahLi4OHh6euLhhx9GaGhovYM5gtlsRkBAgNOO52w8P/0y8rkBPD+13ahBbFdRb9myJXJy\ncgAAERER1Y/369cP/fr1s+etiYjIBpx8RERkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKi\nTkRkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKiTkRkICzqREQGwqJORGQgLOpERAbCok5E\nZCAs6kREBsKiTkRkICzqREQGwqJORGQgLOpERAbCok5EZCAs6kREBsKiTkRkICzqREQGwqJORGQg\nLOpERAbCok5EZCB2Ff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ifiTfflDv8ti5mzRI5L1yQnUT7WNTt9Prr\nYnSJGmtMO9qECcCXX4o/ROvXA7/9BsTGyk5yc506if0IZs+WnUT7WNTtcOyYmHmXlCQ7Sd14e4u+\n/5dekp2EZKuoEFPxZ8xw7OqhanrjDTGK66efZCfRNp18nNo0fbpo/TZuLDtJ3cXHi9EEXBfGta1Z\nA/j5Ab17y05Sd61bixv+3L7xxljUbfTNN8DWrWLIlZ64uwOvvipa7OSaKirE55+Sos3RWjeSnCz2\nJjh9WnYS7WJRt1FKiuh28feXnaT+hg0DTpwQ+02S61m1CmjSRCytqzctW7K1fjMs6jYoLBTdF889\nJzuJbdzdxRBHttZdj55b6VWSk4GlSzmZrjYs6jaYNUv0pet5SdvYWDEcc/du2UnImdasEcNbtbQc\nQH21agUMHSpnvXc9YFGvp6IiscnzmDGyk9jH3V3MJExNlZ2EnEVRxJDAl17Sbyu9yksviaU5zp2T\nnUR7WNTr6W9/A0aO1NeIl9rExgIHDogNhsn4cnOBS5eAvn1lJ7Ffq1ZAv37AwoWyk2gPi3o9nDkD\nZGdre0p1fXh6ihXweBnrGmbNEpum6GVc+s28+CLw3ntiAhX9P4N8vM4xf75YvD8gQHYS9Tz7rJhA\ndfKk7CTkSAUFwNGjoi/aKO67D3jwQdHQov/Hol5HpaViAwGjbQ/XpAmQkADMmyc7CTnS7NnAxIlA\nw4ayk6hryhSxOmplpewk2mFTUVcUBdOmTUN0dDTi4+Nx4sSJq57PzMxEREQE4uPjER8fj+PHj6uR\nVarMTCAkBGjXTnYS9b3wgpjQ8euvspOQI3z/PbB9O/DMM7KTqK97dzEzdtMm2Um0w92WF+Xm5qK8\nvBw5OTk4ePAgUlNTsWD
"text/plain": [
"<matplotlib.figure.Figure at 0x107508b70>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"plt.axis([-1, 11, -1.5, 1.5]);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``plt.axis()`` method goes even beyond this, allowing you to do things like automatically tighten the bounds around the current plot:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD/CAYAAAD/qh1PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4Tmf+BvA7CwkJtdQWrdBUVKeoRBnVBCXWBCHRJCRa\n6cZ0ZUqXGUZrnZlfa7RMtYzYKrWkllhCCFWjRRSldFQVFdqiKknJ9r6/P76NNZG863OW+3Ndrmkk\n7zn3HMfXc57zLB5Wq9UKIiIyLE/VAYiIyLVY6ImIDI6FnojI4FjoiYgMjoWeiMjgWOiJiAzOoUK/\nf/9+JCYm3vL7W7ZsQUxMDOLi4rBs2TJHTkFERA7ytveDc+bMwapVq+Dn53fD7xcXF2Pq1KlIS0uD\nj48P4uPj0a1bN9SpU8fhsEREZDu7W/SBgYGYOXPmLb9/7NgxBAYGwt/fH1WqVEFoaCh2797tUEgi\nIrKf3YU+IiICXl5et/x+Xl4eatSocfVrPz8/5Obm2nsaIiJykNNfxvr7+yMvL+/q1/n5+ahZs6az\nT0NERJVkdx99qZuXygkKCsKJEydw6dIl+Pr6Yvfu3UhOTi7zs9nZ2Y6enojIlEJDQyv9sw4Xeg8P\nDwBAeno6Ll++jNjYWLz22msYPnw4rFYrYmNjUb9+faeEVc1iAf71L2DSJGDECOCll4C6dcv/+eJi\nYPly4PXXgfbtgffeA+68s+yfzcnJQUBAgGuC6wyvxTVGvRZffAEkJwNNmgBvvgm0a3f7n9+/H3j1\n1cs4dqwaPvwQ6NzZPTm1yuZGslWhPXv2qDy9TS5etFr79rVaH37Yav3f/2z7bH6+1Tp6tNXapInV\n+sUXZf/M6dOnHQ9pELwW1xjtWlgsVut771mt9etbramp8nVlnT592rpqldXasKHVOm2abZ81Gltr\nJydMVUJODtCxI9C0KbB1K9C8uW2fr14d+Oc/genTgb59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le164yzPPis7UHGoJbnat9/KGlGPPaY6ifNFRsoezQcPqk7iWoYt9MXFsurj\ns8+qTuIaERHAr7/KmGYiV3r/feCJJ/Sx2qutvL2B5GTjt+oNW+gzMoDGjYHWrVUncQ1PT3ns/Pe/\nVSchIyssBBYulOGIRvXkk9IN+ttvqpO4jmEL/Zw5xr45AWllffIJ8MsvqpOQUa1ZI+u4N2+uOonr\nNGkCPPww8PHHqpO4jiEL/dmzskplXJzqJK5Vrx7Qpw+waJHqJGRUc+ZI14bRGf2lrCEL/YIFsrJe\njRqqk7je8OHm3guTXOfkSdl2c9Ag1Ulcr3dvICcHOHBAdRLXMFyht1rlJazRu21KPfoocP68zJYl\ncqaUFHkq1vO6NpXl5SULtc2frzqJaxiu0H/2mfyhdeyoOol7eHrKDcpWPTlTSYm5GkyA/D1avBgo\nKlKdxPkMV+hL+xSNNrHjdh5/XEYNmHWHe3K+zZuBunWBtm1VJ3Gf4GBZ6CwjQ3US5zNUob90CVi1\nCkhMVJ3EvYKCZGOStWtVJyGjSEmR9z9mM2yY/H83GkMV+rQ0WRrACKvr2eqJJ9h9Q86RmwusW2f8\nUWtlGTwYyMyU915GYqhCv2gRMHSo6hRqxMQA27fL0FIiR6SlAeHhwJ13qk7ifrVqyQic1FTVSZzL\nMIX+hx+AvXuBqCjVSdTw9wcGDOBCZ+Q4MzeYAOm+MdroG8MU+iVLZC9II67HUVlDhrDQk2NOn5a9\nVM3aYAJkHanTp4Gvv1adxHkMU+gXLjTfS9ibde0qkz6MsNUbqbFkiUw2NMPY+fJ4eckTzYIFqpM4\njyEK/YEDspJjWJjqJGp5eckLNLbqyV6LFrHBBMiWnampsrOWEdhV6K1WK8aPH4+4uDgkJSXh1KlT\nN3w/JSUFkZGRSEpKQlJ
"text/plain": [
"<matplotlib.figure.Figure at 0x107d1c9b0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"plt.axis('tight');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It allows even higher-level specifications, such as ensuring an equal aspect ratio so that on your screen, one unit in ``x`` is equal to one unit in ``y``:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD6CAYAAAC8sMwIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHF1JREFUeJzt3XtY1FX+B/D3wMRFQUPNhPopSXl7KM0rlXhBMbTMTFTy\nWpqmrmWKhbdyrYdYa1fdWt1QtyQ1Kc287Jqupustb1FalraarrnMaEImA6Iwzvz++GSTmxf4zuXM\nGd6v5+HpgYaZjwfmzfme77mYnE6nE0REpK0g1QUQEZF7GORERJpjkBMRaY5BTkSkOQY5EZHmGORE\nRJoze/PJ8/LyvPn0REQBq1WrVhV+rFeDHKhcMYHMYrEgJiZGdRl+gW3hwrZwYVu4VLYTzKEVIiLN\nMciJiDTHICci0hyDnIhIcwxyIiLNGZ614nA4MG3aNBw/fhxBQUGYMWMG7rzzTk/WRkREFWC4R755\n82aYTCYsW7YM48aNw6xZszxZFxERVZDhHnnXrl2RlJQEAMjPz0fNmjU9VhQREVWcWwuCgoKCMGnS\nJGzatAlvvPGGp2oiIqJKMHnihKDCwkL07dsX69atQ1hY2C9fz8vLQ3R0tLtPHxBsNhsiIyNVl+EX\n2BYubAsXtoWL1Wr1zRL91atX4/Tp0xg5ciRCQ0MRFBSEoKDfDrlzya3g8mMXtoUL28KFbeFitVor\n9XjDQd6tWzdMnjwZgwYNgt1ux9SpUxESEmL06YiIyCDDQR4eHo45c+Z4shYiIjKAC4KIiDTHICci\n0hyDnIhIcwxyIiLNMciJiDTHICci0hyDnIhIcwxyIiLNMciJiDTHICci0hyDnIhIcwxyIiLNMciJ\niDTHICci0hyDnIhIcwxyIiLNMciJiDTHICci0hyDnIhIcwxyIiLNMciJiDTHICci0hyDnIhIcwxy\nIiLNMciJiDRnNvJN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K3KfySSXszt2AG+9JUMuhYWqq6JAduoU0L07sHy5LI4bOFB1RZ4RHy//\nnltvlZzYuVN1Rd6lXZA7HLLg5oknZAZIVpb8FQ4kTZrIFUZsrNyV//xz1RVRIPr0U5nG17atjIXf\ncYfqijwrLEyGXd98UzpFf/pT4F7lahXk584BvXsDGzbIWFiXLqor8p7QULncff114MEHZfiIyBOc\nTmDePFkkN3++bE1h9vquS+r07Oma+z5woGzoFWi0CfJDh6TncPvtMv4VHa26It/o21f+vS+/DIwb\nx1kt5J4LF4Bhw4C//lV65D16qK7INxo0kCFLs1mmVR4/rroiz9IiyD/+GOjYEZg0SfZKCbShlBu5\nPN539KjckDp7VnVFpKPTp2XKa0mJzO4KhPtKlREeDuTkyB+yhASZJRYo/D7I33oLePJJ2RvlySdV\nV6NOVBSwZo3cuAnEHgV516FDsgtnt26ymriqbt5mMsl03/fek6vdpUtVV+QZfjsy5nBID3zVqsCZ\nleKu4GDZIjQuThYQffSR/y/WIPW2bJGNp2bOlEkCJPfXNm+WtSfHjwNTp/p23xhP88seeWmpzP/c\nvbtqXgLeyNixMs/84YdlqT/RteTkyHtp2TKG+P+Kj5d8+egjYPhwve8/+V2QnzsnszTMZpkr7u/L\n7FXp2VMWED3zjAw/Ef2v118Hpk+XseCkJNXV+KfoaGmfy4sLS0pUV2SMXwX55ZsxLVrI2JW/bXbl\nb1q1khNaXntN9mkJ1DmyVDlOpwxLvvOODEs2baq6Iv8WESG98uho2RpXx8kEfhPkJ04AiYlAr17A\nn/+s1x4PKsXFyZt12TJg4kSGeVV36RLw9NMy/rttm0zXpRszm+XUo4QEmSFXyZPWlPOLuPzmGwnx\nsWNlA3udbzqoEBMjb9p
"text/plain": [
"<matplotlib.figure.Figure at 0x1076ded30>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"plt.axis('equal');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information on axis limits and the other capabilities of the ``plt.axis`` method, refer to the ``plt.axis`` docstring."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Labeling Plots\n",
"\n",
"As the last piece of this section, we'll briefly look at the labeling of plots: titles, axis labels, and simple legends.\n",
"\n",
"Titles and axis labels are the simplest such labels—there are methods that can be used to quickly set them:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEVCAYAAAD6u3K7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt8zvX/x/HHDhjb5HyYCo055JBNSppDLOfDGDZsRCc6\nU6S+P1IJlb5J9k34NiRzaOR8PlRKYzIRfUtCRjkU22LH6/fHuy2H2fG6rvfn87le99vNrWzXPp+n\nj8v1+rzfn/fBzWaz2RBCCCGu4647gBBCCGOSAiGEECJPUiCEEELkSQqEEEKIPEmBEEIIkScpEEII\nIfLkqTuAEPaUmZlJ+/btadSoEXPmzMnzNampqUydOpX9+/fj7u6Oh4cHERER9O/fH4DHHnuMsWPH\n4u/vb5dMycnJzJgxg/j4eDw8PHBzc2PQoEGEhYXZ5fhCOIoUCGEpmzdvpmHDhhw6dIiff/6ZO+64\n44bXTJ8+HW9vb1avXg3A2bNnGThwILVq1eK+++5j9uzZdsuTnp7OkCFD6N27NytXrsTd3Z2kpCSG\nDRuGm5sb/fr1s9u5hLA36WISlvLJJ58QEhJCt27diImJyfM1Z8+eJS0tjYyMDACqVq3KzJkzuf32\n2wF44IEHOHToEPHx8URERDB27FhCQ0Pp0aMH8fHxAGRkZDBlyhT69u1Lnz59GD9+PKmpqTeca926\ndXh7ezN8+HDc3dU/Nz8/P2bMmEH9+vWvOV+OnN+fOnWK9u3bM2LECLp06cL48eN57bXXcl/3xRdf\nMGDAAAD27dvH4MGD6du3L2FhYezYsaNkF1IIpEAIC/npp584cOAA3bp1o3fv3qxevZqLFy/e8Lqn\nnnqKr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KYSUnT8JDD6nnbXXqOO48NWqoFvnjj8NP\nPznuPGYmBcJODh6El1+GJUugbFnHn++NNyAlBWbO9HH8yYRwksxMiIhQw1HbtHH8+e6+G155RXUJ\nX7ni+POZjRQIO0hLU/MW3noLGjZ0zjlLlYLFi2HuXG/273fOOYVwtDfeUA+Sx4513jlHjlSjoyZN\nct45zUIKhB1Mngz16sHQoc497623wv/93yWGDoX0dOeeWwh7O3QIZs6EefMc20V7PTc3+M9/1Dyj\nb75x3nnNQApECX33nXpzzZqlZ3Zm//6XqV3bcQ/FhXCGrCy1hMbrr6sbH2erVk2Nmho2TLqariYF\nogSystSopcmToVYtPRly7n6io+HHH/VkEKKkZs5Uw08feURfhgEDoEEDyGNrcZclBaIE5syBMmVU\nkdCpVi0YNw6eeUYm/gjzOX1atRw+/NC5XUt5+fe/VYE4cUJvDqOQAlFMf/6pRj+8957+NzWo4nDs\nGKxapTuJEEXz8sswfDgEBOhOAnXrqtUK7D3J1awM8NFmTq+/Dj17wl136U6ilC6t1nx69lnpQxXm\nkZAA69erImEUY8fC3r1qFrerkwJRDD/+CDExxpum37EjNGkCH3ygO4kQBctZpfXVVx0zW7q4ypZV\ns7jHjZOJqFIgiuGll2DMGDUT02jeeAOmTIFLl3QnESJ/q1errtrhw3UnuVG/fuq/n36qN4duUiCK\naP9+tezwM8/oTpK3pk2hSxe1j4QQRpWdrTbDeu01Y+7L4O4OU6eqrq+MDN1p9JECUUQTJqglvMuV\n053k5iZNUvMyfvtNdxIh8hYXp3ZO7N1bd5Kb69RJbW360Ue6k+gjBaII4uPVMtuPPaY7Sf7q1FHb\nnEorQhhRVhZMnKiePRh968833lCtHFddqUAKRBFMmKCanF5eupMUbOxYtWTBuXO6kwhxraVLoXx5\n6NpVd5KCtWoFjRvDggW
"text/plain": [
"<matplotlib.figure.Figure at 0x107d57438>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x))\n",
"plt.title(\"A Sine Curve\")\n",
"plt.xlabel(\"x\")\n",
"plt.ylabel(\"sin(x)\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The position, size, and style of these labels can be adjusted using optional arguments to the function.\n",
"For more information, see the Matplotlib documentation and the docstrings of each of these functions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When multiple lines are being shown within a single axes, it can be useful to create a plot legend that labels each line type.\n",
"Again, Matplotlib has a built-in way of quickly creating such a legend.\n",
"It is done via the (you guessed it) ``plt.legend()`` method.\n",
"Though there are several valid ways of using this, I find it easiest to specify the label of each line using the ``label`` keyword of the plot function:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD6CAYAAAC8sMwIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8TNf/x/HXJJEIidhiSe1LlNLS2AlZLEFtJcSWWFrF\nV1FprS2lxbd8i2ppYw9RS2OvrSHWoiQtqpbaasmiYs1Glrm/P6YMv1qSyUxu7vg8H48+OpPcufeT\nI/Oek3vPPUenKIqCEEIIzbJRuwAhhBA5I0EuhBAaJ0EuhBAaJ0EuhBAaJ0EuhBAaJ0EuhBAaZ2fJ\nnUdHR1ty90IIYbU8PDyyvK1FgxyyV4w1i42Nxc3NTe0y8gRpCyNpCyNpC6PsdoLl1IoQQmicBLkQ\nQmicBLkQQmicBLkQQmicBLkQQmicyaNW9Ho9H3/8MZcuXcLGxoZJkyZRpUoVc9YmhBAiC0zukUdG\nRqLT6Vi5ciXDhw9n5syZ5qxLCCFEFpncI2/RogU+Pj4AxMTE4OLiYraihBBCZF2ObgiysbFhzJgx\n7Ny5kzlz5pirJiGEENmgM8cKQTdv3sTf35+tW7eSP3/+R1+Pjo6mdOnSOd29VUhMTMTZ2VntMvIE\naQsjaQuj3G6Ls2fPsnLlSj799NMXbnvkyBFOnjxJ//79n7nN1KlT6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NVQA4fboArq4PyJ8/E4Bp05zp2TOF8uUz1flhgAx9Br/E/8KuK7s4En+EM7fPUNmlMlULV6Vy\n4cpUd65OUdeiFLIvhE6
"text/plain": [
"<matplotlib.figure.Figure at 0x107d7ca90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, np.sin(x), '-g', label='sin(x)')\n",
"plt.plot(x, np.cos(x), ':b', label='cos(x)')\n",
"plt.axis('equal')\n",
"\n",
"plt.legend();"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see, the ``plt.legend()`` function keeps track of the line style and color, and matches these with the correct label.\n",
"More information on specifying and formatting plot legends can be found in the ``plt.legend`` docstring; additionally, we will cover some more advanced legend options in [Customizing Plot Legends](04.06-Customizing-Legends.ipynb)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aside: Matplotlib Gotchas\n",
"\n",
"While most ``plt`` functions translate directly to ``ax`` methods (such as ``plt.plot()`` → ``ax.plot()``, ``plt.legend()`` → ``ax.legend()``, etc.), this is not the case for all commands.\n",
"In particular, functions to set limits, labels, and titles are slightly modified.\n",
"For transitioning between MATLAB-style functions and object-oriented methods, make the following changes:\n",
"\n",
"- ``plt.xlabel()`` → ``ax.set_xlabel()``\n",
"- ``plt.ylabel()`` → ``ax.set_ylabel()``\n",
"- ``plt.xlim()`` → ``ax.set_xlim()``\n",
"- ``plt.ylim()`` → ``ax.set_ylim()``\n",
"- ``plt.title()`` → ``ax.set_title()``\n",
"\n",
"In the object-oriented interface to plotting, rather than calling these functions individually, it is often more convenient to use the ``ax.set()`` method to set all these properties at once:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEVCAYAAAD6u3K7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlYVGX/BvB7ZFiEwcy15PcGRuESW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+vdTxNKQqQmwv8+Sdw+TJw44bsRETW6fp14OJF4Px5IC9PdhrbofkZhL+/P86dO3fX\n80ajEe7u7kWP3dzckJOTc8/tZGVlmSWfuSgKcPy4Hrt2OePHH53w3//qceaMHpUqKahcWUFBgQ5/\n/61DrVqFeOIJE5o0yUfLlnlo3jwfTk733m5OTo7VtYW5sC1us+W2uHRJh++/d8YPPzjjyBFHnDyp\nR26uDm5uCgDAaNShcmUFTzxhQoMGBXj2WeCFF/6HGjUKJSe3PpoXiHsxGAwwGo1Fj3Nzc1GlSpV7\nvr9OnTpaxHpgf/4JrFwJrF4N5OQAXboAoaFA48bAE08Arq66ovfeuAGcOeOAX35xwJ49zli0yB2Z\nmUBwMDB0KODnd/f2s7KyrKYtzI1tcZuttYXJBGzYAKxaBXz3HdC+PdChA/Dqq4CPD1CzJqDTib8l\nRRFF5PhxJxw44IStWyth9uzKaN4ciIgAgoJw34MuW5adnV2m90srEIqilHjs7e2N06dP4+rVq3Bx\nccH+/fsxdOhQSeke3JkzwLx5wCefAH37Ah98ALRqBVS6z0U9Bwegbl3xT/fuwKxZwKlTorgEBoo/\nhIkTgU6dNPs1iKTKzxc
"text/plain": [
"<matplotlib.figure.Figure at 0x107f67cc0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ax = plt.axes()\n",
"ax.plot(x, np.sin(x))\n",
"ax.set(xlim=(0, 10), ylim=(-2, 2),\n",
" xlabel='x', ylabel='sin(x)',\n",
" title='A Simple Plot');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!--NAVIGATION-->\n",
"< [Visualization with Matplotlib](04.00-Introduction-To-Matplotlib.ipynb) | [Contents](Index.ipynb) | [Simple Scatter Plots](04.02-Simple-Scatter-Plots.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
}