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.
udemy-ML/04-Matplotlib/02-Matplotlib-SubPlots.ipynb

667 lines
212 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",
"# Matplotlib Sub Plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import the `matplotlib.pyplot` module under the name `plt` (the tidy way):"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# COMMON MISTAKE!\n",
"# DON'T FORGET THE .PYPLOT part\n",
"\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**NOTE: For users running .py scripts in an IDE like PyCharm or Sublime Text Editor. You will not see the plots in a notebook, instead if you are using another editor, you'll use: *plt.show()* at the end of all your plotting commands to have the figure pop up in another window.**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The Data"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"a = np.linspace(0,10,11)\n",
"b = a ** 4"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.000e+00, 1.000e+00, 1.600e+01, 8.100e+01, 2.560e+02, 6.250e+02,\n",
" 1.296e+03, 2.401e+03, 4.096e+03, 6.561e+03, 1.000e+04])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"x = np.arange(0,10)\n",
"y = 2 * x"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# plt.subplots()\n",
"\n",
"**NOTE: Make sure you put the commands all together in the same cell as we do in this notebook and video!**\n",
"\n",
"The plt.subplots() object will act as a more automatic axis manager. This makes it much easier to show multiple plots side by side.\n",
"\n",
"Note how we use tuple unpacking to grba both the Figure object and a numpy array of axes:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEWCAYAAAB8LwAVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXxU5dn/8c/lQi2iYoVKRS3uNSAgRFx4cEUL1u1n1aK27uICrbiWR+tSrTuiKCirKxQXEAXZBQRUBBL2RYQiBQQligIKKoHr+eMef4Y4wRAyc2dmvu/XK6/MnHOSfI3KxXXOvZi7IyIiUtoOsQOIiEjVpAIhIiJJqUCIiEhSKhAiIpKUCoSIiCSlAiEiIkmpQIhUAjPb38y+NrMdt3KNm9nB6cwlsj1UIEQqyMyWmFlLAHdf6u413H1T4tw7ZnZV3I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CHMbWrSAOXPC/tA76K52JknZvy13nwCsLnVslLsXJ95+AOybqp8vIhFs3BjmMTRuHGZDv/giDBsGv/1t7GRSATHL+RXA8DLOOTDKzArNrG0aM4lIRU2bBkcdFdZROuccmDcP/vIXMIudTCooSoEwszuAYqBfGZc0d/cmQGugnZmVufu4mbU1swIzKygqKkpBWhHZqg0boGNHaNYs7BE9aBC88grsvXfsZLKd0l4gzOxS4AzgYnf3ZNe4+4rE51XAIKBZWd/P3Xu6e76759euXTsVkUWkLBMnhttJDz8Ml10WuoZzzomdSipJWguEmbUC/g6c5e7ry7hmVzPb7YfXwGnAnGT
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Use similar to plt.figure() except use tuple unpacking to grab fig and axes\n",
"fig, axes = plt.subplots()\n",
"\n",
"# Now use the axes object to add stuff to plot\n",
"axes.plot(x, y, 'r')\n",
"axes.set_xlabel('x')\n",
"axes.set_ylabel('y')\n",
"axes.set_title('title'); #; hides Out[]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adding rows and columns\n",
"\n",
"Then you can specify the number of rows and columns when creating the subplots() object:"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAOoUlEQVR4nO3cf6jdd33H8efLZp3MVR02giTRVpZOszKou3QOYVZ0I+0g+adIAmVzFIPOuj+UQYfDSf1ryiYI2VzYpCpojf4xLxIpzFUcYrS3VKtJybiLbr1U1qid/4jWsvf+OKfueHPT+23u99yT5P18QOB8v+eT7/t9ct/3le/58T2pKiRJV77nL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AUeBW4F9wOEk+9YtuxN4sqp+HfgQ8NdjNyqNzdlWN0PO8G8GVqvqbFU9BdwHHFy35iDwsentzwJvTJLx2pTmwtlWKzsGrNkFPDazvQb8zoXWVNXTSX4EvAT4/uyiJEeAI9PNnyb59sU0PYJrWdebda+42r8xYM2VNtsdf87d6sKw2d7QkMDf6GymLmINVXUMOAaQZKWqlgbUH92ianeru8jaSVaGLNtg32U7211/zp3qPlP7Yv/ukJd01oA9M9u7gccvtCbJDuBFwA8vtilpmzjbamVI4D8I7E1yfZKrgUPA8ro1y8AfT2/fDvxrVZ13FiRdYpxttbLpSzrT1y3vAu4HrgI+WlWnktwDrFTVMvBPwCeSrDI5+zk0oPaxLfS9VYuq3a3uImtvWvcKnG1/zld+3S3VjicrktSDV9pKUhMGviQ1MffAX9Sl6wPqvivJ6SSPJPlikleMUXdI7Zl1tyepJKN8vGtI3SRvnj7uU0k+OUbdIbWTvDz
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Empty canvas of 1 by 2 subplots\n",
"fig, axes = plt.subplots(nrows=1, ncols=2)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x0000023521E20588>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x0000023521E5D8C8>],\n",
" dtype=object)"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Axes is an array of axes to plot on\n",
"axes"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2,)"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"axes.shape"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD8CAYAAAB6pa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nNtmVDg1lM6LrgM2AzOAjRGxQ9J6oB0RI8Cvgd9KGqX4b2ll2naHpAeBncAB4KaIeG+SkMNT352eNRXb+9xAbOe2455gsaccV8U/N2Zmlis/WWxmljkXAjOzzDVWCHp5tH8AsW+RtFPSC5Iel3T2IOKW2n1FUkiq5Ra0KnElfTXt8w5J/1dH3CqxJZ0l6UlJz6fPe1lNcTdKem2i+/ZV+Hnq1wuSLqkjbnrvRnK7qbyuErvUzrndW8z+5HVEDPxFcWHub8C5wEzgL8CijjbfAe5O0yuBBwYY+wvAh9L0jXXErhI3tTsNeJriYaXWgPZ3IfA8MCvNf3yAn/UwcGOaXgT8o6bYnwMuAV6aYP0y4BGK5wEuA/48nXO7qbx2bg82t/uV100dEfTyaH/fY0fEkxHxdprdQnGPeN/jJncAdwL/rSFm1bjfBjZExBsAEfHaAGMH8JE0fTo13YsfEU9T3OUzkRXAb6KwBfiopDNrCN1UbjeV15ViJ87tHvUrr5sqBN0e7e98PP+wR/uBg4/2DyJ22RqKCtv3uJIWA/Mj4g81xKscF/gU8ClJz0jaImlogLF/AFwnaQz4I3BzTbEnc6x5UOf79iO3m8rrSrGd2wPL7SnldZWfmOiHXh7tH0TsoqF0HdACruh3XEkfoPh1y+triFU5bnISxSH05yn+S/yTpIsi4s0BxF4F3BsRP5H0WYp79i+KiPd7jF1H3/r1vv2I3VReTxrbuT3Q3J5SbjV1RNDLo/2DiI2kK4HbgOURsX8AcU8DLgKekvQPivN7IzVcVKv6Wf8uIv4XxS9p7qL48vSqSuw1wIMAEfE
"text/plain": [
"<Figure size 432x288 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Empty canvas of 2 by 2 subplots\n",
"fig, axes = plt.subplots(nrows=2, ncols=2)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[<matplotlib.axes._subplots.AxesSubplot object at 0x0000023521ED5E48>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x0000023521F09D88>],\n",
" [<matplotlib.axes._subplots.AxesSubplot object at 0x0000023521F45308>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x0000023521F79D88>]],\n",
" dtype=object)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"axes"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2, 2)"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"axes.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting on axes objects\n",
"\n",
"Just as before, we simple .plot() on the axes objects, and we can also use the .set_ methods on each axes.\n",
"\n",
"Let's explore this, make sure this is all in the same cell:"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAfSklEQVR4nO3de3SU9b3v8fd3i9qCtF6IthUBK3hBxagRta7TCqhVi3Ufb0Av2h7Polq1YrVnt95wd6+zxRvYvd1LN1Wk7elWwYqgouDu3qeKtzZogCj3i0dIgAA1wS0gId/zR2ZwiJMhmWdmnmd+83mtxcrkmSfz+4V8880vz8wnP3N3REQkXH8T9wRERKS41OhFRAKnRi8iEjg1ehGRwKnRi4gErkfcE8imT58+PmDAgLinIYGaP3/+JnevKvW4qmspplx1nchGP2DAAGpra+OehgTKzN6PY1zVtRRTrrrWpRsRkcCp0YuIBE6NXkQkcGr0IiKBU6MXEQmcGr2ISODU6EVEAqdGL8F55E8rmf/+lrinIVJQzdt2ctesd2netrPbH6tGL0GZt3wTE15cwnMLGuOeikhB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zt7PHef7O417l5TVVWV77SkCNLp1wdHV1dE+rWQta26Tq7M9OsNAaRfc8mr0ZvZ+cDfAd929487OaeXmfVO3wbOA+qznSvJVWnpV9V2ZQgx/ZpLV15e+QTwBnCMma01s6uBh4DetP/KWmdmj6TO/YqZzU596GHAPDNbAPwZeMHdXyrKZyFFEXr6VbVduaYGmH7NZa/X6N19TJbDj3VybgNwYer2KuC
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig,axes = plt.subplots(nrows=1,ncols=2)\n",
"\n",
"for axe in axes:\n",
" axe.plot(x,y)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x2352216ce88>]"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de3xU9Z3/8dcHwv1+CYjcFaReQMUUse5aFKvWWnFbrVgvtHWXutW2trvtarut1m5b7e6qa+1Plyr11qroeqEtXqgK2lZQQEi4SIhckwAJBJJwCeTy+f0xZ3AIkwkkc5/38/HIY86c852Zz0xO5pNzzvfz/Zq7IyIiua1DqgMQEZHUUzIQERElAxERUTIQERGUDEREBMhLdQBtNXDgQB81alSqw5AstXTp0h3unp/s19V+LYkUa7/O2GQwatQolixZkuowJEuZ2aZUvK72a0mkWPu1ThOJiIiSgYiIKBmIiAhKBiIigpKBiIhwFMnAzGabWYWZrYxY19/M5pvZuuC2X7DezOwBMysxs0IzmxjxmBlB+3VmNiNi/VlmVhQ85gEzs3i/S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+BvysPbGIAGyu2kdNXYN6EklKhKuMp34iPauMY8mM4xeRoxSuPNaENpJs4SrjXl3St8o4lvTu6yRyjIrKqumc14Fxx+nisSRXuMr4kRsKyO+VnlXGsejIQLJKYeluThnSO2Mu2kl2+LjKeDgXnpK+Vcax6C9GskZTk7OyrEbXCySpDq8yztzJ7HSaSLLG+h172XOgQdcLJKnCVcbP33RO2lcZx6IjA8kaRWW7gcQMWy0STaZVGce
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig,axes = plt.subplots(nrows=1,ncols=2)\n",
"\n",
"axes[0].plot(a,b)\n",
"axes[1].plot(x,y)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x2352229c648>]"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAD8CAYAAACGsIhGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXwU9f348debcF+BGEDugHLfEEHFeiIiWvCsYK2oUKtftd/a/qp4VC22/aK29WitFSwKtoqKKJGiiKgVBYSgQCByhHCFRK5wJ5Dr/ftjJnQJOTbJ7M5u8n4+HvvY2ZnP7Oc9m9m8d+Yz8/mIqmKMMcaUp47fARhjjIl8liyMMcZUyJKFMcaYClmyMMYYUyFLFsYYYypkycIYY0yFLFkYUw4RmSEie0RkXRnLRUReEJE0EVkrIoMDlk0Qkc3uY0L4ojbGe5YsjCnfa8CocpZfCXRzH3cCLwGISBzwODAMGAo8LiItQxqpMSFkycKYcqjqF0B2OUXGArPUsRxoISJtgSuARaqaraoHgE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KYyKRJQvjq4/Wfc8j76VwcY9W/N91/fwOxxhTBksWxjdfp+/n57O/pX+HFvztx4OpF2O7ozGRyr6dxhffZR1m0qxkOrZsxKu3nUPj+tZOYUwks2Rhwm5ndg63zlhBk/p1mTVxGC2b1Pc7JGNMBSxZmLDad/QEt85YwYn8QmZNHEr7Fo38DskYEwQ79jdhc/REAbe/upLMg7n8a9Iwurdp5ndIxpggWbIwYZFXUMRdr68iNesw034yhMS
"text/plain": [
"<Figure size 432x288 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# NOTE! This returns 2 dimensional array\n",
"fig,axes = plt.subplots(nrows=2,ncols=2)\n",
"\n",
"axes[0][0].plot(a,b)\n",
"axes[1][1].plot(x,y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A common issue with matplolib is overlapping subplots or figures. We ca use **fig.tight_layout()** or **plt.tight_layout()** method, which automatically adjusts the positions of the axes on the figure canvas so that there is no overlapping content:"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAAEYCAYAAAAJeGK1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXxU9b3/8deHsCP7JqsBZRGRzRTcWrVuSFtwQQu9XlGxVqu97bW11WrV4rW1amvb3/Xnr9Qi6q1ad1KLC1qtlooCikBYFCFAANlBkDXJ5/fHOeGOYZIMYc6cmeT9fDzmkTNnvpnvJ5OZfPI553u+X3N3REREsk2DuAMQERFJRglKRESykhKUiIhkJSUoERHJSkpQIiKSlZSgREQkKylBiWQRM5tiZhvMbGEVj5uZ/d7MlpnZfDMblukYRTJFCUoku0wFRlbz+HlAn/B2NfBgBmISiY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O8Y0BHgm3HwHOT9j/qAdmAW3MrAtwLjDD3beE07fMAKq8Ol7kw9XbePy9VUw4OZ8BXVvFHY6IRORwE5QDr5rZXDO7OtzX2d3XAYRfKyazrGoal1SmdwE0dYtAWblz6wsL6XhEE244u2/c4YhIhA53mPkp7r42nFF5hpktqaZtVdO4pDK9S7DTfTIwGaCgoCBpG6nbHn93JQvWbOd344bQsmmjuMMRkQgdVgXl7mvDrxuA5wnOIa0PD90Rfq2YbbmqaVxSmd5FhI079nLPK0s5+ej2jB7cNe5wRCRitU5QZtbCzFpWbAPnAAsJpmapGIk3AZgWbhcCl4Wj+U4Etoe
"text/plain": [
"<Figure size 432x288 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# NOTE! This returns 2 dimensional array\n",
"fig,axes = plt.subplots(nrows=2,ncols=2)\n",
"\n",
"axes[0][0].plot(a,b)\n",
"axes[1][1].plot(x,y) \n",
"\n",
"plt.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Parameters on subplots()\n",
"\n",
"Recall we have both the Figure object and the axes. Meaning we can edit properties at both levels."
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtIAAAIZCAYAAACLRdjdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdd3xV9f3H8dcnCSEJI2wIe++hGJZ7UMFRcbZuXMX6q621rYLWvapWa7V1FBXFPQAVLSq4qoCyFMKeYYQNIQNC5v3+/rgHG9OEcTPOvTfv5+NxH/fe7/mec9/3Bk4+Ofd7vsecc4iIiIiIyJGJ8TuAiIiIiEgkUiEtIiIiIhICFdIiIiIiIiFQIS0iIiIiE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e1mluKc2+oNz9jhtWcA7Ur1awts8dpPLtP+ldfetpz+IiJhqbgkwIRZ6Qzq2Jij2jXyO46IiJSxcFMWYyelsXJ7Luce1Zq7ft6HJvXiq+W1Qh3aMRU4MPPGaOCDUu1XerN3DAWyvaEfnwKnm1lj7yTD04FPvWW5ZjbUm63jylLbEhEJO9OXbSdjz34djRYRCTP7C0t44KNlnP/MLHLyi5hwVSp/v/joaiui4TCOSJvZmwSPJjczswyCs288DLxjZtcCG4GLvO7TgDOBNUAecDWAcy7TzO4H5nn97nPOHTiB8QaCM4MkAh97NxGRsPT8N+vo0DSJ4b1a+h1FREQ8s9fuYtzkxWzMzOOyIe0Zd0ZPGiTUqfbXPWQh7Zy
"text/plain": [
"<Figure size 864x576 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig,axes = plt.subplots(nrows=2,ncols=2,figsize=(12,8))\n",
"\n",
"# SET YOUR AXES PARAMETERS FIRST\n",
"\n",
"# Parameters at the axes level\n",
"axes[0][0].plot(a,b)\n",
"axes[0][0].set_title('0 0 Title')\n",
"\n",
"\n",
"axes[1][1].plot(x,y)\n",
"axes[1][1].set_title('1 1 Title')\n",
"axes[1][1].set_xlabel('1 1 X Label')\n",
"\n",
"axes[0][1].plot(y,x)\n",
"axes[1][0].plot(b,a)\n",
"\n",
"# THEN SET OVERALL FIGURE PARAMETERS\n",
"\n",
"# Parameters at the Figure level\n",
"fig.suptitle(\"Figure Level\",fontsize=16)\n",
"\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Manual spacing on subplots()\n",
"\n",
"Use .subplots_adjust to adjust spacing manually.\n",
"\n",
"Full Details Here: https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.subplots_adjust.html\n",
"\n",
"Example from link:\n",
"\n",
"* left = 0.125 # the left side of the subplots of the figure\n",
"* right = 0.9 # the right side of the subplots of the figure\n",
"* bottom = 0.1 # the bottom of the subplots of the figure\n",
"* top = 0.9 # the top of the subplots of the figure\n",
"* wspace = 0.2 # the amount of width reserved for space between subplots,\n",
" # expressed as a fraction of the average axis width\n",
"* hspace = 0.2 # the amount of height reserved for space between subplots,\n",
" # expressed as a fraction of the average axis height"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtIAAAHSCAYAAADBgiw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdeXxU5d3+8c83CRCWsISENez7voUA8ad1qYpLiwtuVVkFl9r6dNHaPm3tU2tb+3T1aasihkUFVNyoCkrVVhFZwh42CWELSUhCWBIgZJn790cGGzFsySRnZnK9Xy9eM3PPmckVkZwrZ+5zH3POISIiIiIiFybC6wAiIiIiIqFIRVpEREREpBpUpEVEREREqkFFWkRERESkGlSkRURERESqQUVaRERERKQaorwOUF1xcXGua9euXscQkUrWrFmT75yL9zqHSCjSfk0kOJ1t3xayRbpr166kpqZ6HUNEKjGzPV5nEAlV2q+JBKez7ds0tUNEREREpBpUpEVEREREqkFFWkRERESkGlSkRURERESq4ZxF2sxSzCzXzNIqjcWa2VIz2+G/beUfNzN7yszSzWyjmQ2v9JqJ/u13mNnESuMjzGyT/zVPmZkF+psUEREREQm08zkiPRsYe9rYo8AHzrlewAf+xwDXAL38f6YDT0NF8QYeA0YBScBjp8q3f5vplV53+tcSEREREQk65yzSzrmPgYLThscBc/z35wA3VBqf6yqsAFqaWXvgamCpc67AOXcIWAqM9T/X3Dn3mXPOAXMrvZeIBIF3Nmbz8ed5XscQEREJCOccMz/JIL/oZI3fq7rrSLd1zmX7w2SbWRv/eEdgX6XtMv1jZxvPrGK8SmY2nYqj13Tu3Lma0UXkfDnn+M3irf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XJ0nJeumcUI8NgtSgVaZF6qNznWLolh8v6tiG6QaTXcUREJMwtT8/n3hfW0Cw6ipfuT6Z32xivIwWEirRIPbR6dwH5RSVcE+IfqYmISPD7x4Ysvv/KerrFNWXOlCTat2jsdaSAUZEWqYeWpOXQKCqCy/q08TqKiIiEseeX7eLxt7eQ1DWW5yYk0qJJA68jBVSNTtU3s++Z2WYzSzOz+WYWbWbdzGylme0ws5fNrKF/20b+x+n+57tWep8f+8e3m9nVNfuWRORsfD7HkrQcLukdT9NG+l1aREQCz+dz/ObdrTz+9hbGDmjH3KlJYVeioQZF2sw6At8FEp1zA4FI4HbgSeBPzrlewCFgqv8lU4FDzrmewJ/822Fm/f2vGwCMBf5uZpq0KVJL1mceJudosaZ1iIhIrSgp8/H9V9bz7McZ3D26C3+7c3jYno9T08Vjo4DGZhYFNAGygcuBhf7n5wA3+O+P8z/G//wVVrHy9jhggXPupHNuF5AOJNUwl4icwZK0HBpEGlf0a+t1FBERCTNFJ8uYOmc1b67P4odX9eaX4wYQGRF6F1o5X9X+XNc5t9/Mfg/sBU4A7wNrgMPOuTL/ZplAR//9jsA+/2vLzOwI0No/vqLSW1d+jYgEkHOOxWnZJPeIo0Xj8PuITUREvJNXeJLJs1exNbuQ340fzK2JnbyOVOtqMrWjFRVHk7sBHYCmwDVVbOpOveQMz51pvKqvOd3MUs0sNS8v78JDi9Rzm7OOsq/ghKZ1iIhIQO3KP8bNTy9nZ+4xnpswol6UaKjZ1I6vA7ucc3nOuVLgdSAZaOmf6gGQAGT572cCnQD8z7cACiqPV/GaL3HOzXDOJTrnEuPjdREJkQu1JC2HCIMr+2tah4iIBMaGfYcZ//RyCotLmTdtFJf3rT/7mJoU6b3AaDNr4p/rfAWwBfgIGO/fZiLwlv/+Iv9j/M9/6Jxz/vHb/at6dAN6AatqkEtEzmBxWjajurWmdbNGXkcREZEw8K/tudz
"text/plain": [
"<Figure size 864x576 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig,axes = plt.subplots(nrows=2,ncols=2,figsize=(12,8))\n",
"\n",
"# Parameters at the axes level\n",
"axes[0][0].plot(a,b)\n",
"axes[1][1].plot(x,y)\n",
"axes[0][1].plot(y,x)\n",
"axes[1][0].plot(b,a)\n",
"\n",
"# Use left,right,top, bottom to stretch subplots\n",
"# Use wspace,hspace to add spacing between subplots\n",
"fig.subplots_adjust(left=None,\n",
" bottom=None,\n",
" right=None,\n",
" top=None,\n",
" wspace=0.9,\n",
" hspace=0.1,)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exporting plt.subplots()"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtIAAAHSCAYAAADBgiw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdd3xUVcLG8d9JIwkkoUMChIROaIKhiGVReBGxYN3FtWBbdn23ukWwdxd9Lau7q7uKKPYCqNjBtgpIVUggtJAECAlJIKRAeua8f+SikU0oaXdm8nw/n3wyc+fOzDMTuHly59xzjbUWERERERE5MQFuBxARERER8UUq0iIiIiIiDaAiLSIiIiLSACrSIiIiIiINoCItIiIiItIAKtIiIiIiIg0Q5HaAhurcubONi4tzO4aIyAlbt27dPmttF7dztCRts0XEVx1tm+2zRTouLo61a9e6HUNE5IQZY3a6naGlaZstIr7qaNtsDe0QEREREWkAFWkRERERkQZQkRYRERERaYBjFmljzDxjTK4xZmOtZR2NMUuNMdud7x2c5cYY86QxJtUYk2SMGVXrPjOc9bcbY2bUWn6yMSbZuc+TxhjT1C9SRERERKSpHc8e6ReAKUcsmw18Zq3tD3zmXAc4B+jvfM0Enoaa4g3cBYwFxg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bTt0s7t2N5vQYXaWNMB2r2JscDBcBbwDl1rGoP36We2+pbXtdzzgRmAsTG6uxjItIwu/NL+Cg5m1+c3od2OupcRFoxj8fy4jcZPPzJVgxw37QhXDG2NwEB/n9676bQmN8gk4B0a20
"text/plain": [
"<Figure size 864x576 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# NOTE! This returns 2 dimensional array\n",
"fig,axes = plt.subplots(nrows=2,ncols=2,figsize=(12,8))\n",
"\n",
"axes[0][0].plot(a,b)\n",
"axes[1][1].plot(x,y)\n",
"axes[0][1].plot(y,x)\n",
"axes[1][0].plot(b,a)\n",
"\n",
"fig.savefig('subplots.png',bbox_inches='tight')\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\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.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}