You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

981 lines
836 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>\n",
"___\n",
"# Advanced Matplotlib Commands Lecture\n",
"\n",
"### NOTE: There is no video for the notebook since its really just a reference for what method calls to look for. We also highly recommend doing a quick StackOverflow search if you're in need of a quick answer to what Matplotlib method to use for a particular case.\n",
"\n",
"In this lecture we cover some more advanced topics which you won't usually use as often. You can always reference the documentation for more resources!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Logarithmic scale"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to set a logarithmic scale for one or both axes. This functionality is in fact only one application of a more general transformation system in Matplotlib. Each of the axes' scales are set seperately using `set_xscale` and `set_yscale` methods which accept one parameter (with the value \"log\" in this case):"
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlsAAAEOCAYAAAC+btKoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd4FFX3wPHvoXekijQVBCkKiA1pRgERUamKiEpRbIj6\nE5SmL0FfAqIiKEhRwIIUfQ2gKEiNkNC7QGiCIIpI7yXl/P6YjYQYJJtsdnY35/M8+5CdmZ05m5Cb\ns/eee0dUFWOMMcYYkzmyuR2AMcYYY0wos2TLGGOMMSYTWbJljDHGGJOJLNkyxhhjjMlElmwZY4wx\nxmQiS7aMMcYYYzKRJVsmYIjIQhEZm9VjMMZcnojcKSIJIlL6MsdNEJE5mRRDfxHZlhnn9hVfvn8R\naS0i67w4XkRkk4g098X1g5klWyFERD4VkUQRGZxiexnP9oZuxWaMCS6ZmaT4SAxwlar+ASAi9Tzt\nXHk/xvAOUMeP13ONiGTHeb//Setr1Fn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onITlW1e88ZY4JBLRF5F4jH6Y3pcpnjTTIi0gHn78cu4BqcCTtJ6zOZ\n4NMXZ3QBABHJj7Mu2qvAiFQSLcEpT8nyf/PT1LP198EibwFlknq2PMWOy4Gyyaf3Jjs+Bpigqp94\nnnfGGfap64vgjTHGBC4ReRFn5ltpnNm70UBPVb3ckJUJAiIyAWiPkzw/pKrnXA4pYGW0Zus2nPHi\nN0XkgIisF2eV7yTVcabWJ1lP6rMZjDHGhBhV/UBVr1PVfKpaVlUfsUQrdKhqZ1XNo6oPWqL17zKa\nbJXFGSI8gnOrg+7AZ54
"text/plain": [
"<matplotlib.figure.Figure at 0x10b54ab10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axes = plt.subplots(1, 2, figsize=(10,4))\n",
" \n",
"axes[0].plot(x, x**2, x, np.exp(x))\n",
"axes[0].set_title(\"Normal scale\")\n",
"\n",
"axes[1].plot(x, x**2, x, np.exp(x))\n",
"axes[1].set_yscale(\"log\")\n",
"axes[1].set_title(\"Logarithmic scale (y)\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Placement of ticks and custom tick labels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can explicitly determine where we want the axis ticks with `set_xticks` and `set_yticks`, which both take a list of values for where on the axis the ticks are to be placed. We can also use the `set_xticklabels` and `set_yticklabels` methods to provide a list of custom text labels for each tick location:"
]
},
{
"cell_type": "code",
"execution_count": 95,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnEAAAEOCAYAAADmEUGxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VNX9//HXyR4StiTsuyK4FWgBFVQMVAVcEKwLKkuK\nbV2q/X2l2m8riFCQLi791qUuVQuCaN2gUmRxIYrKJrKKsmmAsCcQyMJMkpnz+2MmIYQsM9luJnk/\nH4/7uDNn7rn3EwfDm3vuPddYaxER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WsfEFvBNvi3qeoxKuxfMsSJiIhIw7f1\nyFaGzR3G3hN76ZnYkyVjltC1RVenyzpD6ZNL06ZNC7hvTV3N9zW+YdNOpdo7+9cbKtnG+rep6jEC\n6S8iIiKNwOd7PufSVy9l74m9DOw0kC8mfFEvA1x11VSI+wjIBC4u1T4AWGut3RHgNtU9hoiIiDRi\n7337Hle+diVZrixu6HkDH439iMQmiU6XVSuCDXExZfWz1nqA6cA4Y0w0gDGmHXAdMC3QbfxtvzfG\nbDLGJAZ7DBEREWm8/rH2H9z01k24PW7u6nsX79zyDrGRsZV3DFHBPLFhCHAvvqHLm40x3wKLrLU5\nANbap40xLuAlY8wWoC8w1lq7uGgfgWwDJACtORUYCbK/iIiINCLWWiZ9Mok/ff4nAKYPns6kyydh\njHG4stplrC19s2fDYoyxDf1nFBERaawKPAX8cuEvmb1xNuEmnJeuf4kJP57gdFlVZozBWhtQ+qyp\nu1NFRERE6lROfg43vXU
"text/plain": [
"<matplotlib.figure.Figure at 0x10b3de690>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(figsize=(10, 4))\n",
"\n",
"ax.plot(x, x**2, x, x**3, lw=2)\n",
"\n",
"ax.set_xticks([1, 2, 3, 4, 5])\n",
"ax.set_xticklabels([r'$\\alpha$', r'$\\beta$', r'$\\gamma$', r'$\\delta$', r'$\\epsilon$'], fontsize=18)\n",
"\n",
"yticks = [0, 50, 100, 150]\n",
"ax.set_yticks(yticks)\n",
"ax.set_yticklabels([\"$%.1f$\" % y for y in yticks], fontsize=18); # use LaTeX formatted labels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are a number of more advanced methods for controlling major and minor tick placement in matplotlib figures, such as automatic placement according to different policies. See http://matplotlib.org/api/ticker_api.html for details."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Scientific notation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With large numbers on axes, it is often better use scientific notation:"
]
},
{
"cell_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+T0REqtaYV710\n1NCHP3Xq1GPPMzMzdZaciEgFWVlZZGVl1Xq9kM6grener5Us3wr4AfABcBTvnrJPAGc75zZWsY7O\noBURCVFJaQljXhnD/PHzG/QM2irv/Wpm75rZ3RWWTwAexLsX7B68e8NeUlXQi4hI7byz4R125YV+\nt1ZdG0dEJApd8MIFTOg/gav6X6Vr44iINEVff/81q3atYmyfsSGvo7AXEYkyj2c/zrVnX0tSfFLI\n60TMPWhFRKRmhwoP8cKqF1h548paraeWvYhIFJmzag6juo+iS6sutVpPYS8iEiWcc0zLnsbNQ26u\n9boKexGRKJG1OQuAzG6ZtV5XYS8iEiXKWvVmtb+gsMJeRCQKbD24lUU5i7iq/1V1Wl9hLyISBWYu\nnclVZ11FamJqndbX0EsRkQhXcLSAp1Y8xYdXf1jnbahlLyIS4eaumcuAkwdw2kmn1XkbCnsRkQhX\n1+GWwRT2IiIRLHt7NrvydvGz3vW795PCXkQkgk3Pns5NQ24irllcvbajSxyLiESoPYf3kDEtg423\nbCQ9Jb3SZcxMlzgWEYlmT694ml+d/qsqg742NPRSRCQCHS09yoylM5h32bwG2Z5a9iIiEejt9W/T\nOa0zAzsObJDtKexFRCLQtCXTuHlo/YZbBlPYi4hEmHV71vHl7i/5dZ9fN9g2FfYiIhFmevZ0Jg+a\nTGJcYoNtUwdoRUQiSG5hLi+ufpHVv13doNtVy15EJII8v/J5zu9xPp1bdm7Q7SrsRUQihHOO6dnT\nG/TAbBmFvYhIhFiYs5D4ZvGMOHVEg29bYS8iEiHqc9vBmijsRUQiwJYDW/hwy4dccdYVYdm+wl5E\nJAI8sfQJJpw1oc63Hay
"text/plain": [
"<matplotlib.figure.Figure at 0x10b7a0f10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 1)\n",
" \n",
"ax.plot(x, x**2, x, np.exp(x))\n",
"ax.set_title(\"scientific notation\")\n",
"\n",
"ax.set_yticks([0, 50, 100, 150])\n",
"\n",
"from matplotlib import ticker\n",
"formatter = ticker.ScalarFormatter(useMathText=True)\n",
"formatter.set_scientific(True) \n",
"formatter.set_powerlimits((-1,1)) \n",
"ax.yaxis.set_major_formatter(formatter) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Axis number and axis label spacing"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEhCAYAAABoTkdHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4VOXZx/HvTQJhRwyggmwqsQgKKlhxjbZq7aJVXxWk\nKO5WaLX4drOLVLu3bhXccd/6uqOlVi3EBUHCIgKyLy4IspNASCDJ/f5xJskwJCQTkjkzk9/nuuaa\nOWdmztzniOeX53nOYu6OiIhIXTULuwAREUktCg4REYmLgkNEROKi4BARkbgoOEREJC4KDhERiYuC\nQ+JmZo+a2Ztxfmelmd3cAL/dIMup52/3NLNyMzuhkX/nVDMrM7Oujfk7ja0+/04kNWSGXYBIiknE\niU9TgYPcfV0Cfqsx/Rj9cZqWFBwi8bHG/gF3LwVSPTRw98Kwa5DGob8GZJ+Z2dFmNsnMvjKzQjOb\nYWZnVfPRVmb2kJltNbP1ZvaHmOVkmtlYM1thZjvMbJ6ZXVOPeh40s2VmVmRmy83sD2bWIur9W8xs\nqZmdY2YLzWybmU0xs8NilnNR5HM7zOx94Kh93RZmdmhk/W+Imtc3UsNVkelTI11iXaO2yx1m9rmZ\nFZvZl2b2TC11XGVmn0Rq32hmeVHLG2lmu8zsG2Y2P/KZ6WY2IOr7+5nZk2b2aWQ7LjKzMdX8zsVm\nNjOyjA1m9i8z6xB5b7euqsj0W2Z2tZmtimyHV82sc8wyb4ys6zYze93MLoneHhI+BYc0hPbAc8Cp\nwNHAG8CrsTti4EfAamAQcCNwg5n9KOr9h4HvA1cDXwNuBf5sZpfXtRAzM+ArYGhkGTcAI4Ffxnz0\nIOA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yUiUpv129e
"text/plain": [
"<matplotlib.figure.Figure at 0x106d4c710>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# distance between x and y axis and the numbers on the axes\n",
"matplotlib.rcParams['xtick.major.pad'] = 5\n",
"matplotlib.rcParams['ytick.major.pad'] = 5\n",
"\n",
"fig, ax = plt.subplots(1, 1)\n",
" \n",
"ax.plot(x, x**2, x, np.exp(x))\n",
"ax.set_yticks([0, 50, 100, 150])\n",
"\n",
"ax.set_title(\"label and axis spacing\")\n",
"\n",
"# padding between axis label and axis numbers\n",
"ax.xaxis.labelpad = 5\n",
"ax.yaxis.labelpad = 5\n",
"\n",
"ax.set_xlabel(\"x\")\n",
"ax.set_ylabel(\"y\");"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
"# restore defaults\n",
"matplotlib.rcParams['xtick.major.pad'] = 3\n",
"matplotlib.rcParams['ytick.major.pad'] = 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Axis position adjustments"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Unfortunately, when saving figures the labels are sometimes clipped, and it can be necessary to adjust the positions of axes a little bit. This can be done using `subplots_adjust`:"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEmCAYAAABvd5dxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VfWd//HXhwQSQsKOYZWSALKIoIhApRo3rNW6VB0t\nFrTgNi7VwemmnZFf69COjtO6/KyyuotKiysqblHEDQhLkVAwoAgiOyQhZP/OH+feJCQhkOTmnru8\nn4/Hedx7z3Y/Nzz4fM75fs/3HHPOISIi8auV3wGIiIi/VAhEROKcCoGISJxTIRARiXMqBCIicU6F\nQEQkzqkQiDSSmVWa2YQjrHN6YL2e4YpLpKlUCEQaYGZvm9mcWrO7A/N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X2u/zo/fIyLSkIvnXcwFAy/g2pOuDdt3mhnOOTua\ndcN9+WiCmSUDCUCimSWZWQKwABhqZpeYWRJwN7DSObchsOmTwFQz62lmvYCpwNxwxi4i0hTbCrbx\n4dcfcuXxV/odymGFu7P4d0AR8GvgqsD7u5xzu4BLgel4VxSdDFT91ZxzjwGvAv/A6yh+xTk3M7yh\ni4g03tyVc7l8yOWktoncbk1fmoZaipqGRCSSVLpK+j/Ynxcuf4GTe54c1u+O2KYhEZF48t6m9+iQ\n3IGRPUb6HUqDVAhERFrIjOUzuO6k6zA7qgNz36gQiIi0gJ0HdrIobxFXDbvK71COSIVARKQFPLHq\nCS4ZfAkdkjv4HcoRqRCIiISYc45ZObMi6ilkDVEhEBEJscWbF5PQKoGxvcf6HcpRUSEQEQmx4DOJ\nI72TOEjjCEREQmjPwT1
"text/plain": [
"<matplotlib.figure.Figure at 0x10b7b4950>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 1)\n",
" \n",
"ax.plot(x, x**2, x, np.exp(x))\n",
"ax.set_yticks([0, 50, 100, 150])\n",
"\n",
"ax.set_title(\"title\")\n",
"ax.set_xlabel(\"x\")\n",
"ax.set_ylabel(\"y\")\n",
"\n",
"fig.subplots_adjust(left=0.15, right=.9, bottom=0.1, top=0.9);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Axis grid"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With the `grid` method in the axis object, we can turn on and off grid lines. We can also customize the appearance of the grid lines using the same keyword arguments as the `plot` function:"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAloAAADMCAYAAACr+w2dAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4FFXWwOHfzQaBBELYQSFsLiwSFAUVEUQUQUFcGXE0\niCi4jIDLOKKo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MTWU4JRen5AH2yiU7L/t0kbrqWc5vcL7FEQkhRMX930//x67kXbRv2J6nrnzKZ+eRRksIUSkv\n//dldibvpH3D9vy9x9+tDkcIISpsy9EtvLbqNQCm3jSVsOAwn51LxmgJIby2NXErXaZ0Ic+dx8/D\nfubKFld6/RgyRksIYYV8dz5XTruSdQfXMarrKN4f8L7XjyFjtIQQPuPWbkYsGkGeO4+Rl4ysVJPl\nLLLWoR1JLvZjlzw++PUD1h1cR9OIprza51Wfn69CjZZS6mGl1HqlVLZSalqJ2/oopbYrpTKUUiuU\nUi1K3P6aUuq4UuqYUuqfZgZvR3YaQ1NVTsnFKXmAPXL54NcPWHtgLU0jmvLPa+3/X9r39SvGZ7H7\nm11eCM0gudiPHfI4kHaAf6z4BwDv9n+XujXr+vycFb2idRB4CfjYc6dSqj4wBxgHRAMbgFketz8I\nDAQ6ARcBNymlHqh62EIIKxxMO8jT3z8N+K9ImUDqlxACgEe/e5T0nHRuvuBmbrnwFr+cs0KNltZ6\nvtZ6IZBc4qZbgK1a67la6xzgBaCzUqrwO5L3AG9orQ9rrQ8DE4E4UyK3KTuvRectp+TilDzA+lwK\ni9Sg8wcx+ILBlsZSUVK
"text/plain": [
"<matplotlib.figure.Figure at 0x1084dc3d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axes = plt.subplots(1, 2, figsize=(10,3))\n",
"\n",
"# default grid appearance\n",
"axes[0].plot(x, x**2, x, x**3, lw=2)\n",
"axes[0].grid(True)\n",
"\n",
"# custom grid appearance\n",
"axes[1].plot(x, x**2, x, x**3, lw=2)\n",
"axes[1].grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Axis spines"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also change the properties of axis spines:"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgA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3AlcCK4D7a+vKTTY7H5XL5V63MGt4LCZ5LCZ5LCZJ\nKrWy/4yBny9xeBuwNSLejYiDwD7gjjrlG4EnI+L1iDgDbAe+XFtUbqXjecYv5kkei0kei0kei99S\namXnIkf4K4HzlfVsc4eAoTq1Q/nPquuWSRpovkUzM2uHIoG/GBir2TYGLJmi9kxNnaaoNTOzLppx\niUNJVwMvR8Tiqm1/CdwQEZ+rqX0NeDAi/i6/fznZOrgfiojRvCh2AFvYVrVniRbfqcxhZdJ97rXK\neCwqyngsKsp4LCrKRJSaXuawSOD3AaeAocq0jqTdwEhE3FdT+x3gPyPib/L764CnI+IjzTZoZmbt\nMeOUTkScBZ4Dtkvqk7QGuAV4uk75buAuSavyefutwLfb2bCZmTWn6GmZm4E+sumZPcCmiDgiabmk\nMUmDABHxfeAbwEvAUeBNYLjtXZuZWcMKBX5EjEbEn0TE4oj4WER8N9/+y4joj4iRqtodwCqy0P8i\n8EbKX9Qq+qU1SRslvSrpjKRfSHpE0rz6JnQjX+Cr2udHki6kPBaSPi5pf35wdVLS17vZa6c1OBYP\nShqRNCrpRUmru9lrp0naLOkVSeckPTVDbcPZ2al/RG39otYcV2gsgA8A9wCXA58F1gFf7VaTXVJ0\nLACQ9CVgITD9B01zU9F/I4uAHwA/BJYBg2TvsueTomPxBeBO4Hrgg8BPqD+1PJcdAx4AnpyuqOns\njIi23simfv4XWFG1bRfwcJ3a75Cd1VO5fyNwvN099erWyFjU2XcLsK/Xz6FXYwH0A68Dvwf8Brik\n18+hF2MB3A38uNc9z5K
"text/plain": [
"<matplotlib.figure.Figure at 0x10b7d5c90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(figsize=(6,2))\n",
"\n",
"ax.spines['bottom'].set_color('blue')\n",
"ax.spines['top'].set_color('blue')\n",
"\n",
"ax.spines['left'].set_color('red')\n",
"ax.spines['left'].set_linewidth(2)\n",
"\n",
"# turn off axis spine to the right\n",
"ax.spines['right'].set_color(\"none\")\n",
"ax.yaxis.tick_left() # only ticks on the left side"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Twin axes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sometimes it is useful to have dual x or y axes in a figure; for example, when plotting curves with different units together. Matplotlib supports this with the `twinx` and `twiny` functions:"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAb8AAAEECAYAAAC4HjrEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xmc1fP+wPHXu30PiYtL1ixZsmQtzRXZd7nZQq5cwkW6\n1rRZ0g/ZolKpdBFlKYTEUJFKhETq1k2KirapppqZ9++P95nmzNrMmXPm+z3nvJ+Px3nMOd9zzvd8\nZu513r0/38/n/RZVxTnnnEsn1YIegHPOOVfVPPg555xLOx78nHPOpR0Pfs4559KOBz/nnHNpx4Of\nc865tOPBzznnXNoJVfAToZYIQ0VYLMJaEWaLcEbkuWYi5ImwToT1kZ/3BT1m55xLWSJdEZmJSDYi\nw0t5zQOI5CFySpHjjyKyCpGViPSriuFWRI2gB1BEDWAJ0EaVX0Q4G3hNhEMjzyvQWBXfme+cc4n3\nK9AXOB2oW+xZkX2BS4BlRY7fAJwHHBY58hEi/0V1SCIHWxGhyvxU2ahKH1V+iTx+F1gEHB15iRCy\nMTvnXMpSfQvV8cCfpbxiIPBvYGuR452Ax1Fdjupy4DHgmoSNMwahDiQi7Ao0B76PHFJgsQhLRBgu\nQpPgRuecc2lMpAOQjer7JTzbApgT9XhO5FhohDb4iVADGA28qMrPwCqgFdAMywQbAv8JboTOOZem\nRBoADwG3lvKKBsDaqMfrIsdCI2zX/AAQQbDAtxm4BUCVDcDsyEtWinAzsFyE+pHnnHPOVY1ewChU\nfynl+SygUdTjxpFjoRHK4AcMA3YGzlIlt4zXKSVkryLiC2Kcc66CVFXK+dJ2wB6IdI08b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WwfN351zS697dAt9uu9malLgEvtxc29OXm2sZXxmBLx2FKvhh+w6XAG1UaYxVDXhNhL1EaAKM\nA+4DdgK+AsYENlLnnIuD0aPhqaes0MrYsRYA42LgQFsq+te/2rU+V0jopz1FmAP0AnYGrlaldeR4\nPWAV0FKV+YXf49Oezrnw+/prm+bctMkWuPzzn3E68dKl1qcvK8vavJ9//nbf4tOeISLCrsABWGWA\nQoVSVdkILCBkxVKdc648/vgDLrrIAl/nznDDDXE8+S23WOC78MJyBb50FNrgJ0INYDQwIpLZFS2U\nClYstWFVj8055yojNxcuuwwWL7b1KAMHFttzHru33rJbw4bwzDNxOmnqCWVtTxEEC3ybgfy1uUUL\npYIVS11f0jl69eq17X5GRgYZGRnxHqZzzsXkvvtg0iRo2hTGjYM6deJ04vXrC7YzPPQQ7LFHnE6c\nekJ5zU+E4cBewFmqbIkcu57C1/zqAyvxa37OuSTy+utWaax6dZg8Gdq2jePJb7vNVs+0agVffFGh\nxn/pds0vdMFPhEFY2/tTI9f18o/vDPwMdMZaaPQFWqtSrDOwBz/nXBhNmwanngrZ2TBgQLz6yEbM\nmgXHHWfzp7NmQcuWFXp7ugW/UF3zi+zb64K1v/hdhPUirBPhMlVWARcDDwN/AscAHYMbrXPOld/c\nuVZeMzvbtt/l9+mLi5wcO2lenvU/qmDgS0ehy/ziwTM/51yYLF0KJ5xgP88/3/bz1YjniosnnoBu\n3aBZM4uy9etX+BTplvl58HPOuQRavRratLGYdNJJttClbt04fsD//geHHAIbN1r3hrPOiuk06Rb8\nQjXt6ZxzqWTTJjjvPAt8hxwC48fHOfCpws03W+Dr0CHmwJeOPPNzzrkEyMmxePTWW1Zh7PPPrTlt\nXI0dax/SqBH8+GOlaqN55uecc65SVKFrVwt8O+wA77+fgMC3di3ceqvd79cvjkVB04MHP+eci7O+\nfWHIENu8PmECtEhEEcZ
"text/plain": [
"<matplotlib.figure.Figure at 0x109b88690>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax1 = plt.subplots()\n",
"\n",
"ax1.plot(x, x**2, lw=2, color=\"blue\")\n",
"ax1.set_ylabel(r\"area $(m^2)$\", fontsize=18, color=\"blue\")\n",
"for label in ax1.get_yticklabels():\n",
" label.set_color(\"blue\")\n",
" \n",
"ax2 = ax1.twinx()\n",
"ax2.plot(x, x**3, lw=2, color=\"red\")\n",
"ax2.set_ylabel(r\"volume $(m^3)$\", fontsize=18, color=\"red\")\n",
"for label in ax2.get_yticklabels():\n",
" label.set_color(\"red\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Axes where x and y is zero"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAADtCAYAAABAv+VSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHsBJREFUeJzt3Xl4VdW9//H3AVIZkpMAMkRUxCgyKOEWh5YoJPRWHJCp\nFBABi9BaaVF/yIUL2Ag1eEUFh4JSbFVAStUHMdLeC1JMiUhtQSCVBKWNRQICQQkZCIHkZP3+WE0M\nkJDhDPsMn9fz7Cc5h332+bKfcz4s1l57LZcxBhERCQ/NnC5ARER8R6EuIhJGFOoiImFEoS4iEkYU\n6iIiYUShLiISRlr48dgaKyk+5XK50BBciQAub16slrqISBhRqIuIhBGFuohIGFGoi4iEEYW6iEgY\nUaiLiIQRhbqISBhRqIuIhBGFuohIGFGoi4iEEYW6iEgYUaiLiIQRhbqISBhRqIuIhBGFuohIGFGo\ni4iEEYW6iEgYUaiLiIQRhbr4xdKlS7nhhhto2bIl99133wX3ffbZZ4mPjycuLo4pU6ZQXl4eoCpF\nwo9CXfyiS5cu/OIXv2Dy5MkX3G/jxo089dRTZGRk8MUXX5Cbm8tjjz0WoCpFwo9CXfxi+PDhDB06\nlHbt2l1wv5UrVzJ58mR69OhBbGwsqampvPrqqwGqUiT8KNTFUdnZ2SQmJlY/TkxMJD8/n4KCAger\n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AZGX\nB2PGQPv28PHH6m7xF3W/iIjfrVsH118PQ4faIYsKdP9RS11E/ObUKXjkEdvVkp4O3/mO0xWFP7XU\nRcQvduywfeYFBbBrlwI
"text/plain": [
"<matplotlib.figure.Figure at 0x1071d7110>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"ax.spines['right'].set_color('none')\n",
"ax.spines['top'].set_color('none')\n",
"\n",
"ax.xaxis.set_ticks_position('bottom')\n",
"ax.spines['bottom'].set_position(('data',0)) # set position of x spine to x=0\n",
"\n",
"ax.yaxis.set_ticks_position('left')\n",
"ax.spines['left'].set_position(('data',0)) # set position of y spine to y=0\n",
"\n",
"xx = np.linspace(-0.75, 1., 100)\n",
"ax.plot(xx, xx**3);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Other 2D plot styles"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to the regular `plot` method, there are a number of other functions for generating different kind of plots. See the matplotlib plot gallery for a complete list of available plot types: http://matplotlib.org/gallery.html. Some of the more useful ones are show below:"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [],
"source": [
"n = np.array([0,1,2,3,4,5])"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAs8AAADVCAYAAACooB1jAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xt8VPWd//HXJ+EOIdxFEIiXWhUtINrrrtJaxdqtu+r+\nWqtusd2V7da1LUbrUlwMUEvtirW1upbWC9Zqbasoa20jFYKV3hQlIgp4IYCiQEDCJYFc5vP745zA\nZJgkk+RMZiZ5Px+PPJg553vO+Q75MnzmO5/z+Zq7IyIiIiIircvLdAdERERERHKFgmcRERERkRQp\neBYRERERSZGCZxERERGRFCl4FhERERFJkYJnEREREZEUKXgWEZFuz8yWm9n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CWdXTwk1/MLO33H1hersr0rzI0jbcvdrd57r7\nlvD5bwlmOiYnaf4lgk+P69y9iuDriMTi2SIZkcJYNpTyJFlG41aymbs/HqYZ7GqmyZ0Ek2qJ30B/\nCVjg7u+GZV1vJZjB7hLM7H/NbG8zP2sy3T9JLm3VNszsKIJcyLVJdo/n8J34EOTwjDCzwe7+frr6\nJNIe4Vg+kSA3HYIZvAozc4JcruvdfWem+tcVubs+THeQxq3kirAs64EwxShx93ia1gMuD7d1Ff8N\n/E8z+5TKmqXSEjybWQ/gQYIVcZIV6B5A07rCewhmRQqAQ8Fz+CYv0mHu3q6FZeLG8n3u/rqZ9Se4\ncXM1wZ35dxGs9HR+wnEau9JhnT1uw2M1dqXDUh27ZjYAuBk4p5kmyeKFAUnO0yXHbZIPE5JmqYzd\nyL/Cs+A3/SBBbcDmFgLZBwyMe15IMCuSuPJdpy+5eNNNN3WLa3an1xrlWHb3/e7+orvH3H0H8J8E\npX/6a+x2zWsGb02d/zo
"text/plain": [
"<matplotlib.figure.Figure at 0x10a72ed90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axes = plt.subplots(1, 4, figsize=(12,3))\n",
"\n",
"axes[0].scatter(xx, xx + 0.25*np.random.randn(len(xx)))\n",
"axes[0].set_title(\"scatter\")\n",
"\n",
"axes[1].step(n, n**2, lw=2)\n",
"axes[1].set_title(\"step\")\n",
"\n",
"axes[2].bar(n, n**2, align=\"center\", width=0.5, alpha=0.5)\n",
"axes[2].set_title(\"bar\")\n",
"\n",
"axes[3].fill_between(x, x**2, x**3, color=\"green\", alpha=0.5);\n",
"axes[3].set_title(\"fill_between\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Text annotation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Annotating text in matplotlib figures can be done using the `text` function. It supports LaTeX formatting just like axis label texts and titles:"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVB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g4EFzh/Dxx9CvX+7fN27DOCr6VnS56bRzy+2rkrS++WRVQgiR\nHxERJim8/75pcM6tdb+vY+H+hYQ9FYZy04uTW98xxMdDixZw+LCzIxFCFCSHD8N995m1mgcOzP37\nohOiGf7dcOb2mUugzy2GQrswt04Mvr7w3HPQqRMcOuTsaIQQBcHBgyYpTJ0KQ4bk/n1pOo0hK4Yw\nuNFgOtXoZL8AHcDtq5KGDjVT3HbqBD/+CHfe6eyIhBDu6sABU3303nt5u1MAmLJ1CvFJ8bzd0fqF\ndxzN0jsGpZS/UmqFUipeKfWHUurRHMoNU0qlKKUuK6Xi0v+9J7/7HTTI1AN27gzh4fmPXwhReIWF\nmWvI++/nPSls+nMTn+z8hCX9llDEs4h9AnQgq+8YPgcSgbJAU+B7pVSY1jq7VoDtWut8J4OsHn0U\nvLygSxczVL15c6u2LIQo6HbtMuMUPv8c+vbN23vPxZ9j0PJBzO0zlyqlqtgnQAez7I5BKeUDPAS8\nrrW+qrXeBgQDeails03//jBjBnTvDtu2OWqvQgh3tm0bPPAAzJyZ96SQkpbCoOWDGNp4KF1rdbVP\ngE5gZVVSHSBZa30sw3PhQIMcyt+llIpSSkUopV5XSlkSS69eMH8+9OljJrsSQoicbNgADz5orhm5\nHbyW0esbXgdgQscJFkfmXFYmBl/gcpbnLgMlsym7CbhTa10O6As8CvzHqkC6dIFvvoFHHoFVq6za\nqhCiIFm1ylwjvvnGXDPy6ttD37LkwBIW912Ml4fb9+PJxMrfJh4oleU5PyAua0Gt9Z8Z/n9QKTUB\n+D9gatay48ePv/H/oKA
"text/plain": [
"<matplotlib.figure.Figure at 0x109b0aa50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"ax.plot(xx, xx**2, xx, xx**3)\n",
"\n",
"ax.text(0.15, 0.2, r\"$y=x^2$\", fontsize=20, color=\"blue\")\n",
"ax.text(0.65, 0.1, r\"$y=x^3$\", fontsize=20, color=\"green\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Figures with multiple subplots and insets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Axes can be added to a matplotlib Figure canvas manually using `fig.add_axes` or using a sub-figure layout manager such as `subplots`, `subplot2grid`, or `gridspec`:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### subplots"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEWCAYAAAApTuNLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHc9JREFUeJzt3X2MXNV9xvHvg+1CLL/ITbGaxi6NrFi1jQRKSIuApotp\nBapKatEmiBRQEoSK5D+o24pKrRUvDlgh4g8kFFAkILJxCa0qXBfhKLSBTYXVKpAKN3JN0iCX1MSx\noX7Z3YJbCL/+ca83dyezO2dm79w5s34+0pU9d86cOTvzSL+5r0cRgZmZ2aCdN+gBmJmZgQuSmZll\nwgXJzMyy4IJkZmZZcEEyM7MsuCCZmVkWXJDMzCwLSQVJ0mZJL0o6I+mxDm23SDoq6ZSkRyQtqmeo\nNgycFeuG82JVqVtIrwNfAB6drZGka4G7gKuBi4A1wN1zGaANHWfFuuG82JSkghQRfxcRfw+c6ND0\nVuDRiHglIk4D24HPznGMNkScFeuG82JVdR9D2gAcqDw+AKyUtKLm97Hh56xYN5yXc0DdBWkJcLry\neBwQsLTm97Hh56xYN5yXc8DCmvubBJZVHi8HApioNpLkO7oOUERo0GMgMSvgvAya82LdmEte6t5C\nOghcUnl8KXAsIk62NoyIWpZt27a5ry6WjCRnBZwX58V5GYa+5ir1tO8Fki4AFgALJZ0vaUGbpruA\n2yStK/ftbgW+OudR2tBwVqwbzotVpW4hbQXeAv4c+MPy/38pabWkCUmrACLiG8CXgOeBw8CrwGjd\ng7asOSvWDefFpiQdQ4qIu5n5nP+lLW0fAB6Y47iSjYyMuK+M5JwVyPd7ybWvf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
"<matplotlib.figure.Figure at 0x1070b7e50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(2, 3)\n",
"fig.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### subplot2grid"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEWCAYAAAApTuNLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+sHWW97/H3x7YHaKCkgo1IEUkD97SQQPhx5EDFUg6B\neAQrXuCI0PDjEr0259Sqp96rDS0FGiD8wQ1BQ8KPgIpgDFgbSkSh1UujF5CAHOSHEASKpQX7g2Jb\ntfR7/3hm1+li7b1n1pq11qy1P69k0q5Zz5793bO/e5418zzzHUUEZmZmvfaBXgdgZmYG7pDMzKwm\n3CGZmVktuEMyM7NacIdkZma14A7JzMxqwR2SmZnVQqEOSdI8SY9L2iHp9lHaLpC0TtJmSbdKmlBN\nqGZmNsiKniG9AVwF3DZSI0lnAAuBU4FDgWnAle0EaGZmY0OhDikifhwRPwE2jtJ0LnBbRDwfEVuA\npcAlbcZoZmZjQNVjSEcCT+dePw1MkTS54u9jZmYDpuoOaV9gS+71O4CA/Sr+PmZmNmDGV7y9d4FJ\nudf7AwFszTeS5IquZmYDKCLU6tdWfYb0LHB07vUxwPqI2NTYMCK8FFgWL17c8xj6ZfG+8r7yvurt\n0q6i077HSdobGAeMl7SXpHFNmt4FXCZpejZutAi4o+0ozcxs4BU9Q1oEbAO+AXwh+/+3JB0iaauk\nqQAR8VPgemAV8ArwMrCk6qDNzGzwFBpDiogrGf5+ov0a2t4I3NhmXJaZNWtWr0PoG95XxXlfFed9\n1T2q4rpf6W8qRS++r5mZdY4kokaTGszMzFpSdFLDZEn3S3pX0iuSPj9C26slrZW0SdIjkmZUF66Z\nmQ2qomdI3wZ2AB8CLgS+I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otlib.figure.Figure at 0x10a08ce10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax1 = plt.subplot2grid((3,3), (0,0), colspan=3)\n",
"ax2 = plt.subplot2grid((3,3), (1,0), colspan=2)\n",
"ax3 = plt.subplot2grid((3,3), (1,2), rowspan=2)\n",
"ax4 = plt.subplot2grid((3,3), (2,0))\n",
"ax5 = plt.subplot2grid((3,3), (2,1))\n",
"fig.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### gridspec"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.gridspec as gridspec"
]
},
{
"cell_type": "code",
"execution_count": 112,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEWCAYAAAApTuNLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+sHNV5xvHvk2sDcY1dh2KVxpRGblBtI4ES0iAg6QVa\ngaqSurQJIgWUQFGR/Ad1W1EptWLjAAoRUpFQQJGAFEMJadMQiiAKNOamArXiRwWl1IRCXVITY5vY\nYDs2CYa3f8xcZ7zZvTs7O7P3jPf5SCt71+fcc3be1/PuzM6cq4jAzMxstr1ntidgZmYGLkhmZpYI\nFyQzM0uCC5KZmSXBBcnMzJLggmRmZklwQTIzsySUKkiSVkl6UtJbku7o03a1pK2S3pB0m6S59UzV\n6uBY2jhxvrdL2SOkV4EvALfP1EjSucDVwFnACcBS4JphJmi1cyxtnDjfW6RUQYqIb0XEPwE7+zS9\nFLg9Il6IiDeB9cBnh5yj1cixtHHifG+Xur9DWgE8W3j+LLBY0qKax7HmOZY2TpzvCai7IM0H3iw8\n3w0IOLrmcax5jqWNE+d7AubU/PP2AgsKzxcCAewpNpLkFV1nEBGa7TlQMpbgeNpw2pTvzvX+holn\n3UdIzwMnF56fAmyLiF2dDSNi4MfatWsr9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K53iKl\njpBqH9SfMnoaxRFS3RxPq6pt+e5cn9mojpDMzMwa5YJkZmZJcEEyM7MkuCCZmVkSXJDMzCwJLkhm\nZpYEFyQzM0uCC5KZmSXBBcnMzJLggmRmZklwQTIzsyS4IJmZWRJckMzMLAkuSGZmlgQXJDMzS4IL\nkpmZJcEFyczMkuCCZGZ
"text/plain": [
"<matplotlib.figure.Figure at 0x10a341c50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"\n",
"gs = gridspec.GridSpec(2, 3, height_ratios=[2,1], width_ratios=[1,2,1])\n",
"for g in gs:\n",
" ax = fig.add_subplot(g)\n",
" \n",
"fig.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### add_axes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Manually adding axes with `add_axes` is useful for adding insets to figures:"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEVCAYAAACv2pHlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XdcFNcWB/DfLE3piArYFTsq9hILWNI1lsSoqFgwGkue\niYkv1idqqinGVHuPvWANGgXsBTWiLqiAgh0QkN6WPe+Pq4QqbZfZZc/385mP7HLnzgGHOTt3bpGI\nCIwxxpjcFHIHwBhjjAGckBhjjOkITkiMMcZ0AickxhhjOoETEmOMMZ1gLHcALyNJEncBZIwxPUFE\nUnn21/k7JCLS6W3BggWyx6DP8ckZY0BAABQKBR4+fFiq+CRJwp9//in7700XfoeVJT59iFHX49ME\nnb5DYkybunfvjsePH6NmzZql2u/JkyewtbXVUlSMGS5OSEwvvPgUplBo5qZepVLB2Ni41MkIQJn2\nYYwVT+eb7HSdu7t7mfc9ceIEFAoFjIyM8vzbqFGjnDLnz5+Hm5sbzM3NUa1aNYwcORIxMTF56tmw\nYQNcXF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hubo4hQ4bgf//7H1JTU3H69GkcOHAAo0ePLlDW09MTa9asQUhICOLj\n4/HFF19g3LhxOd/Pzs5Geno6srOzoVKpkJGRkbNsw+DBg6FUKrF3715kZGRg4cKFaNu2LZo2bVph\nP2t5ODsDf/8tdxS6b+9eYNAguaNgjAHQveamfM0VVJjc45Dq169P27ZtIyKie/fukZWVFd2/fz+n\n7NKlS8nBwaHQcUje3t4
"text/plain": [
"<matplotlib.figure.Figure at 0x10a0a39d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"ax.plot(xx, xx**2, xx, xx**3)\n",
"fig.tight_layout()\n",
"\n",
"# inset\n",
"inset_ax = fig.add_axes([0.2, 0.55, 0.35, 0.35]) # X, Y, width, height\n",
"\n",
"inset_ax.plot(xx, xx**2, xx, xx**3)\n",
"inset_ax.set_title('zoom near origin')\n",
"\n",
"# set axis range\n",
"inset_ax.set_xlim(-.2, .2)\n",
"inset_ax.set_ylim(-.005, .01)\n",
"\n",
"# set axis tick locations\n",
"inset_ax.set_yticks([0, 0.005, 0.01])\n",
"inset_ax.set_xticks([-0.1,0,.1]);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Colormap and contour figures"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Colormaps and contour figures are useful for plotting functions of two variables. In most of these functions we will use a colormap to encode one dimension of the data. There are a number of predefined colormaps. It is relatively straightforward to define custom colormaps. For a list of pre-defined colormaps, see: http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [],
"source": [
"alpha = 0.7\n",
"phi_ext = 2 * np.pi * 0.5\n",
"\n",
"def flux_qubit_potential(phi_m, phi_p):\n",
" return 2 + alpha - 2 * np.cos(phi_p) * np.cos(phi_m) - alpha * np.cos(phi_ext - 2*phi_p)"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {},
"outputs": [],
"source": [
"phi_m = np.linspace(0, 2*np.pi, 100)\n",
"phi_p = np.linspace(0, 2*np.pi, 100)\n",
"X,Y = np.meshgrid(phi_p, phi_m)\n",
"Z = flux_qubit_potential(X, Y).T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### pcolor"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWIAAAEECAYAAAAS8T49AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztvXuwLUldJvr9qtZae6999jmnD49GpRGdFqS7uTYPHxOK\n3fIwIBz1KhOOMiPozL3OwCUcBkO4EdwetVsUYYwbTPgYudK0AqIiw+My4NW5IzYC4xUEm7EfoNg0\n3dB00/Tpc84++7EelfePzFz55apfrqq19tpn7XN2fhE7dq6srKqsrKyqL39PMcYgIyMjI2N1KFbd\ngYyMjIyjjvwizsjIyFgx8os4IyMjY8XIL+KMjIyMFSO/iDMyMjJWjPwizsjIyFgx8os4IyMjY8Vo\n9SIWkZeLyMdFZFdE3tLQ9pUicr+IPCIibxaR7nK6mpGRkXFpoi0j/iKAXwRw86xGIvJ8AK8G8GwA\nTwRwJYAb99PBjIyMjEsdrV7Expj3GmP+bwAPNzR9CYCbjTF3GWPOALgJwL/cZx8zMjIyLmksW0Z8\nDYDb6PdtAC4XkVNLPk9GRkbGJYNlv4g3AZyh32cBCIDjSz5PRkZGxiWDZb+ItwCcoN8nARgA55Z8\nnoyMjIxLBp0lH+92ANcCeJf7/TQADxhjTnMjEckh3zIyMlrDGCP72V96xw2GW22b32OM+Yb9nG9e\ntHoRi0gJoAugBNARkTUAI2PMeKrpWwHcIiLvAPBlADcAuEU75g1r/yj6PU68msdKmE5u67drdbOO\nOwsl3fJeIbUy1x0rw6Liw6OH8X3rjwEAnOwW7n852d6/bG1S3nj0ht3/cRvhWJcHCc7G1zwaALB5\nxWPD+R/3tZNy53FPmJ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{},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"p = ax.pcolor(X/(2*np.pi), Y/(2*np.pi), Z, cmap=matplotlib.cm.RdBu, vmin=abs(Z).min(), vmax=abs(Z).max())\n",
"cb = fig.colorbar(p, ax=ax)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### imshow"
]
},
{
"cell_type": "code",
"execution_count": 117,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAATUAAAEECAYAAABJOaMMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXvMbdtVH/YbY679nXOur42oElIJEGl52xEGB2gLKuA2\naaqqUVSktERtCJWKREobBanQilgtdknTRlVF2zRKlBg3EEGAJIJEtCKtSkEhlWLVYBrziEITHokD\nsZzaXN9zzrfXHKN/jMccc+21v/Ode77jc23tqbvufnzrrL0ec/7mb/zGY5Kq4tIu7dIu7ZOl8Ys+\ngUu7tEu7tLtsF1C7tEu7tE+qdgG1S7u0S/ukahdQu7RLu7RPqnYBtUu7tEv7pGoXULu0S7u0T6p2\nAbVLu7RL+6RqtwI1IvpmInovET0iou9+wr7fQkQfJKL/j4j+PBEd7uZUL+3SLu3Sntxuy9T+IYD/\nEsC7b9qJiH4PgG8D8HYAnwXgswG881lO8NIu7dIu7WnarUBNVX9YVf8agA8/YdevB/BuVf0FVf0I\ngHcB+Pef8Rwv7dIu7dJu3e5aU3sLgPeXz+8H8GlE9Kl3/DuXdmmXdmm77a5B7WUAHymfPwqAALzx\njn/n0i7t0i5tt901qL0C4E3l86cAUAC/ece/c2mXdmmXttuWOz7eBwC8FcBf9s9fDODXVfWf1p2I\n6FIa5NIu7QU1VaVn+fd09UbF8ZXb7v7Lqvrbn+X3nrbdCtSIqAE4AGgAFiK6B2BV1b7Z9XsAvIeI\nvg/APwbwDgDv2TvmH7v65wEAqgqF0bloqoD43+B/UwDiO6n/TXxfh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MRX
"text/plain": [
"<matplotlib.figure.Figure at 0x10a083b10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"im = ax.imshow(Z, cmap=matplotlib.cm.RdBu, vmin=abs(Z).min(), vmax=abs(Z).max(), extent=[0, 1, 0, 1])\n",
"im.set_interpolation('bilinear')\n",
"\n",
"cb = fig.colorbar(im, ax=ax)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### contour"
]
},
{
"cell_type": "code",
"execution_count": 118,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEECAYAAAArlo9mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXeYJFd19/+p6px7evLM5pyTtNqkTRJCEkECScZggsmv\nDQ7g9/fiRPKLsV9jDNhggw0GRBCgAJZIAgmtdldhc855d2Yn9kznVOn+/qiZZb3elaq6e2Zndvvz\nPPNoZ1T3VnV11feee+4550pCCGrUqFGjxo2PfL0voEaNGjVqjA41wa9Ro0aNm4Sa4NeoUaPGTUJN\n8GvUqFHjJqEm+DVq1Khxk1AT/Bo1atS4SagJfo0aNWrcJFgSfEmSPixJ0k5JkoqSJH3zVY79qCRJ\n3ZIkJSVJ+oYkSa7qXGqNGjVq1KgEqxb+ReAzwH++0kGSJN0NfAzYCEwGpgN/U8kF1qhRo0aN6mBJ\n8IUQ/yWEeAoYfJVD3wX8pxDimBAiBfxf4D0VXmONGjVq1KgC1fbhzwf2X/b7fqBJkqS6Kp+nRo0a\nNWrYpNqCHwRSl/2eBiQgVOXz1KhRo0YNm1Rb8LNA+LLfI4AAMlU+T40aNWrUsImzyv0dBhYDjw/9\nvgToFUIkLj9IkqRaic4aNWrUKAMhhFRuW6thmQ5JkryAA3BKkuSRJMlxlUO/A7xPkqS5Q377jwPf\nusZF136E4FOf+pSl4zp+9ASHP/GZss6h59LE//0Tlo83VAXtw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yTAs+PYsdX2wF2esyVabaxGaM4vssRNV6etGRgiBoajo+corjJa5Z17lbFq+HqFpSA4HjkAA\nVziIIxjEHavD09SIp6k
"text/plain": [
"<matplotlib.figure.Figure at 0x10b038c10>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
"cnt = ax.contour(Z, cmap=matplotlib.cm.RdBu, vmin=abs(Z).min(), vmax=abs(Z).max(), extent=[0, 1, 0, 1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3D figures"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To use 3D graphics in matplotlib, we first need to create an instance of the `Axes3D` class. 3D axes can be added to a matplotlib figure canvas in exactly the same way as 2D axes; or, more conveniently, by passing a `projection='3d'` keyword argument to the `add_axes` or `add_subplot` methods."
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [],
"source": [
"from mpl_toolkits.mplot3d.axes3d import Axes3D"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Surface plots"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAwQAAAFdCAYAAAC95ar0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXmYZHV97/8+a+1V07O0wDCbDM7AICOyiCAyMURNAleT\nmJ/3/n65/G4eQ6JochEfvWIIqJcYA9clT5ToNQtyI2gEjIk/EAgo4AwwMMwwazP7zkzP0t21nao6\ny/f3R/Xn1PecOqf26q7u/r6ep5+Z7q4+dc6pqs/3+9neH4kxBoFAIBAIBAKBQDA3kaf7BAQCgUAg\nEAgEAsH0IRwCgUAgEAgEAoFgDiMcAoFAIBAIBAKBYA4jHAKBQCAQCAQCgWAOIxwCgUAgEAgEAoFg\nDiMcAoFAIBAIBAKBYA6jNvm90CQVCASC6Uea7hMYYMQ6JRAIpopZ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iAw+lQ9R6pgvMxKNygKBYDqhDCf1\nnpEARSQSCc0ud4JlWdA0zZ1fUC6XYdt2VwMgB8UG8vaZRDyoETustIjwqxbx2QNh5wXdIhyCWYw/\nrUv1ioVCAaZpIplMtjxkrN06UJpqDFR7Emi6r6ZpKBaL7vPyJUxz3UHgoz9A40Zl/z0KalSm6BMA\nt7+BIktz6d4KBILuCVISyuVyiMfjiEQiDf+2lbWDmmwBIJFIuD1ulmW5AaUwqc+ZCtl9XddDS4vo\nOoNUi0gOm46lqioikYiw8YKOEA7BLCVoyBhtEBljyGQyfTEYlBHwzy/w9x+Q8fJvfkm3v9Hmd67Q\nqFGZ7lGjRmWCXpNKpeKWLYlGZYFA0Cp8dlmWZTdLkEqlmgaVWrHblGlQVdXTl0B/T3aOb9YlqU+y\nYbRpnsn4S4scx4FlWZ4
"text/plain": [
"<matplotlib.figure.Figure at 0x10a0bd650>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(14,6))\n",
"\n",
"# `ax` is a 3D-aware axis instance because of the projection='3d' keyword argument to add_subplot\n",
"ax = fig.add_subplot(1, 2, 1, projection='3d')\n",
"\n",
"p = ax.plot_surface(X, Y, Z, rstride=4, cstride=4, linewidth=0)\n",
"\n",
"# surface_plot with color grading and color bar\n",
"ax = fig.add_subplot(1, 2, 2, projection='3d')\n",
"p = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=matplotlib.cm.coolwarm, linewidth=0, antialiased=False)\n",
"cb = fig.colorbar(p, shrink=0.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Wire-frame plot"
]
},
{
"cell_type": "code",
"execution_count": 122,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcwAAAFdCAYAAACO4V1gAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXecFPX5x99TttxeA1EiKMVYAoKIikqTplT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51A8dgOgCJC3qs/Jp9iHNlPbqqeJj28C8Q5fFWhiN1wUlWMZoovAjmAp1MID0d\nioth/36Rli11vN6Mv53DgmTev7XBtDad6UgAOq0udR/HYNZzUlW+hkIhIDMeXWWwh399Ph9ut5vC\nwsKMeodHureVKLxoLb5WBWlFKnRVFf71Lzdz57ooLRU49liDH34QOO00nVtvDdGzp1Ybb7NOYc/1\ne3/fSWRSArC8VhcnpFt9OAaznpKs8hWiWzSAShfUVOXaanuSyZG80Fiftb31Jp0c3XffyQwalMeB\nAwLTp4e49loFSYJgEJYvl5k82Uv79hpPPRXEpkQXOX9tUFc+y4rmRSsqAQhEFYRpmhbRz3VaXTKH\nYzDrGfbJHImGONs1V10uFwcPHszIopNOSNbyaq1+zmTh30y0pxzuOcxMU16O7qOPBEaOzEVVYdmy\nXzjtNB1VldB1EZdLZOhQgwEDVK65xsuwYVnMnx+gQYP416gvpPN8JbvnlZEAtM4nimLUJri8qS5O\nSLdiOAazHpFM89Uad2VVvto9ypr4IlkFPen2c2YKe/jZWTASI4oiu3dLDBuWTTAI+fkGQ4YcTevW\nGr16hbn6aj/Z2WUL+vTpIS68sCGDBmWxZo0ft7v+3tfKPlPpFHTFbnjtHmTskPZE50k2qDu2X9T5\nXkRzZNfjOwBEij1iJdk
"text/plain": [
"<matplotlib.figure.Figure at 0x109e0e890>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(8,6))\n",
"\n",
"ax = fig.add_subplot(1, 1, 1, projection='3d')\n",
"\n",
"p = ax.plot_wireframe(X, Y, Z, rstride=4, cstride=4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Coutour plots with projections"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcwAAAFdCAYAAACO4V1gAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJz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ntdFoJBgI4Ha7sVgs43RUk5f+XLoulwu9Xh8T01TERVN1rPH/KyjH6Xa7e2RQT5dB3UIwpxCKUPrO\nlwQk+4ANdzblWLpkU4nyglJeZCJm05fe7ndrWhodHR3o9foJlzk7WWPRvS3KyRAXlWU5Zl0ONah7\n//79LFq0CKvVOmbHOVoIwZwCxGe+hkIh3G436enpCX9+JK3sJuMLKt7drFarYw+7EmPqXcQ+Gc9x\nJDR3q9FrZHT9rINUKhUWsxmX0ylcsyNkoIXmSOOiY3XPxluhg5W6/OIXv+BHP/qREEzB+NNf5mui\nFt9wZ1P2ZrD9hUKhlMVkUpH0EwgE8Hg8qFQqrFZrbOWubFtZ1fdu7D2dRNQflDh5Vgeyhsr8IFmW\nntdcbzBER7V5vRhNpnE6yqlDIvfSYHHR+Ht2LOpFE3kG48XU6XRis9lSsu/xRgjmJEWJNQ6U+TqY\neyqVsykHewg9Hg/dXV1kZGai1+uHtf1UEW9FKwOvJUnq4UZSXEjx9E7UGO9V/VhQlhWiNDNE/dkQ\nVWesFNpDlOcEUU5PkiQsFgtdXV3oDYYpGauaLAx2z6ayXnSgfSeCy+WaEtYlCMGcdAyV0DPYTZzq\n2ZTx2+2Ny+nE5XKRlZ09rrGukTaEH6yAfaAuMEOJ6ERPXFLVHwStnhxzDrkz1Bw8Y+TgGRULC/wo\n2qjRatHr9Xg8ngmRADT
"text/plain": [
"<matplotlib.figure.Figure at 0x109e08610>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(8,6))\n",
"\n",
"ax = fig.add_subplot(1,1,1, projection='3d')\n",
"\n",
"ax.plot_surface(X, Y, Z, rstride=4, cstride=4, alpha=0.25)\n",
"cset = ax.contour(X, Y, Z, zdir='z', offset=-np.pi, cmap=matplotlib.cm.coolwarm)\n",
"cset = ax.contour(X, Y, Z, zdir='x', offset=-np.pi, cmap=matplotlib.cm.coolwarm)\n",
"cset = ax.contour(X, Y, Z, zdir='y', offset=3*np.pi, cmap=matplotlib.cm.coolwarm)\n",
"\n",
"ax.set_xlim3d(-np.pi, 2*np.pi);\n",
"ax.set_ylim3d(0, 3*np.pi);\n",
"ax.set_zlim3d(-np.pi, 2*np.pi);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further reading"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* http://www.matplotlib.org - The project web page for matplotlib.\n",
"* https://github.com/matplotlib/matplotlib - The source code for matplotlib.\n",
"* http://matplotlib.org/gallery.html - A large gallery showcaseing various types of plots matplotlib can create. Highly recommended! \n"
]
}
],
"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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}