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.

610 lines
184 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 Figure Object"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import the `matplotlib.pyplot` module under the name `plt` (the tidy way):"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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": [
"___\n",
"### Matplotlib Object Oriented Method\n",
"Now that we've seen the basics, let's break it all down with a more formal introduction of Matplotlib's Object Oriented API. This means we will instantiate figure objects and then call methods or attributes from that object."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The Data"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [],
"source": [
"a = np.linspace(0,10,11)\n",
"b = a ** 4"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 52,
"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": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
"x = np.arange(0,10)\n",
"y = 2 * x"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18])"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Creating a Figure"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The main idea in using the more formal Object Oriented method is to create figure objects and then just call methods or attributes off of that object. This approach is nicer when dealing with a canvas that has multiple plots on it. "
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Figure size 432x288 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**NOTE: ALL THE COMMANDS NEED TO GO IN THE SAME CELL!**\n",
"\n",
"To begin we create a figure instance. Then we can add axes to that figure:"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdsAAAE/CAYAAAAOr2mgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6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wK6e5/PdbQeJiI3ARoCZmZkCY0mahN5rs4897rVZ6VDKvkFq0P91OWhhZs4CswCdTmfgGkn14J3G0vIUCduHI+L53Vb7fGDPgDXzPHmqGeB4Fk83S5pC3mksjaZI2N4EXAS8r/v1cwPWfB74k56bol4BXFLgmJIqYpuVRreksI2Ia1lsqKsiYp7FO4zfB3wmIn4beBD4te7aDvCWzHxzZn4rIt4LbO++1OYnbpaSNB1ss1JxkVm/y6OdTifn5uaqHkNqPdustDwRcUdmdvq3+wlSkg5im5XGy7CV9BS2WWn8DFtJgG1WKpNhK8k2K5XMsJVazDYrTYZhK7WUbVaaHMNWahnbrDR5hq3UIrZZqRqGrdQCtlmpWoat1HAL+/azaesOtn1tr21WqohhKzVUZvKZuV1cdvNOHrPNSpUybKUGss1K9WLYSg1im5XqybCVGsI2K9WXYStNOdusVH+GrTTFbLPSdDBspSlkm5Wmi2ErTRnbrDR9DFtpSthmpell2EpTwDYrTTfDVqox26zUDIatVFO2Wak5DFupZmyzUvMYtlKN2GalZjJspRrob7PvXX8Kv2mblRrDsJUq1t9mP3DBaZxwtG1WahLDVqqIbVZqj5HDNiJeCFzfs+kFwLsz88961pwDfA74enfT1szcPOo
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Create Figure (empty canvas)\n",
"fig = plt.figure()\n",
"\n",
"# Add set of axes to figure\n",
"axes = fig.add_axes([0, 0, 1, 1]) # left, bottom, width, height (range 0 to 1)\n",
"\n",
"# Plot on that set of axes\n",
"axes.plot(x, y)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeQAAAE/CAYAAACXV7AVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4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iIiEjMWri0iKi+bGEJ3zuDUqZBERCQll1bX87a1Sbrw4nV6JsX7H6XAqZBERCQmPrS2mrjHAnDD6qlNzKmQREQl6xxsaeWzdLi4fkUpW325+x+kUKmQREQl6f3trLweO1IXVhUBOpUIWEZGg5pxj0apCzu/fnSnD+vgdp9OokEVEJKi9WVjBtr2HmTsl9Oc8bo0KWUREgtqi1YX0Torl0+PS/I7SqVTIIiIStHZX1PDStv18ITeDhNjQn/O4NSpkEREJWkvWFBFtxpcmZvodpdOpkEVEJCgdOd7AE+t3c9WYgQzoFR5zHrdGhSwiIkFpWd5uqo83MG9q+H7VqTkVsoiIBJ2AN+fxuIxkLhqc7HecLqFCFhGRoPPqu2UUHawJ6wuBnEqFLCIiQWfR6kIG9kpgxujwmvO4NSpkEREJKu/uq2Z1/kG+NGkIsdGRU1OR8ysVEZGQsHh1IQmxUdx0SYbfUbqUCllERIJGxdE6nt60hxvGp9O7W5zfcbqUCllERILG428Wc7whwNzJmX5H6XIqZBERCQp1DQEefqOIS7P7kt2/h99xupwKWUREgsLzW/ay//DxiLkQyKlUyCIi4rsTcx4P7duNj2f38zuOL1TIIiLiu43FVbxVcoi5UzKJigrfOY9bo0IWERHfLVp
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Create Figure (empty canvas)\n",
"fig = plt.figure()\n",
"\n",
"# Add set of axes to figure\n",
"axes = fig.add_axes([0, 0, 1, 1]) # left, bottom, width, height (range 0 to 1)\n",
"\n",
"# Plot on that set of axes\n",
"axes.plot(a, b)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding another set of axes to the Figure\n",
"\n",
"So far we've only seen one set of axes on this figure object, but we can keep adding new axes on to it at any location and size we want. We can then plot on that new set of axes."
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"matplotlib.figure.Figure"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(fig)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Code is a little more complicated, but the advantage is that we now have full control of where the plot axes are placed, and we can easily add more than one axis to the figure. Note how we're plotting a,b twice here"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfIAAAFdCAYAAAD42+/rAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdeVzVVf7H8dcBBMGFRQFBQDRIcUvsKpbVpEaWFZaaaYu4xYzVr2WWX838SrNmypppypqmhsYF25hySlrcylYXUMQW1yBB2QQUEBVZ7uX8/rhXQgUEBL7cy+f5ePDg3vNd7vsLyuee7z3f71Faa4QQQghhn5yMDiCEEEKIlpNCLoQQQtgxKeRCCCGEHZNCLoQQQtgxKeRCCCGEHZNCLoQQQtgxKeRCdEJKqdeVUk+0wX5PKqUGtPZ+hRANU3IduRCORymVBfgDFqAa2Ar8Rmud3Qr7/goYA5jrNEdrrbdd7L6FEM0nPXIhHNctWuvuQABQALzSivt+QGvdvc5XmxZxpZRLW+5fCHsmhVwIB6e1rgBWA4PPtCmlViql/lzn+f8qpfKVUnlKqflKKa2UCmvua9XdTinVSyn1sVKqTCm1Qyn1Z6XUZtuyUNu6LnW2/UopNd/2eLZSaotS6kWlVDHwpK19rlJqn1KqRCm1QSnVr2U/FSEchxRyIRycUsoDuANIbmD5DcBvgeuAMOBXrfTSrwKngD5ArO2rOaKAg4Af8Bel1K3An4ApgC/wLfBuK2UVwm5JIRfCca1RSpUCZUA08NcG1psOrNBa79FalwOLm7Dvl5VSpbavtHMXKqWcganAIq11udZ6L5DQzPx5WutXtNZmrfVp4Nf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
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure()\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1]) # Large figure\n",
"axes2 = fig.add_axes([0.2, 0.2, 0.5, 0.5]) # Smaller figure\n",
"\n",
"# Larger Figure Axes 1\n",
"axes1.plot(a, b)\n",
"\n",
"# Use set_ to add to the axes figure\n",
"axes1.set_xlabel('X Label')\n",
"axes1.set_ylabel('Y Label')\n",
"axes1.set_title('Big Figure')\n",
"\n",
"# Insert Figure Axes 2\n",
"axes2.plot(a,b)\n",
"axes2.set_title('Small Figure');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's move the small figure and edit its parameters."
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfIAAAFdCAYAAAD42+/rAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdeVxWZf7/8deluG+AiqKAYpC7paKYbZahbaMtZpqlpuWM1deyabGyGp2xrFmymmp+Nma0UlpJi1tZVmqouBVuYYKsKQqIiuzX7w/uGDTFDTjcN+/n43E/5L7Ocn8Olu/7nHOd6zLWWkRERMQ91XG6ABERETl7CnIRERE3piAXERFxYwpyERERN6YgFxERcWMKchERETemIBephYwx/zHGPFkF+z1sjOlU2fsVkZMzeo5cxPMYYxKBNkAxUAisAf5krU2uhH2vBAYAReWaI6y1P5zrvkXkzOmMXMRz/cFa2xTwB/YCL1fivu+z1jYt96rSEDfGeFXl/kXcmYJcxMNZa/OAhUC339qMMW8aY/5W7v0jxph0Y0yaMeYuY4w1xoSc6WeV384Y09IY85kxJscYs94Y8zdjzCrXso6udb3KbbvSGHOX6+fxxpjVxpgX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tt6SlpeHj48O9994LwLZt25g8eTJvv/02aWlpHDhwgJSUlDM6vlWrVrFz505WrFjBzJkz2b59+zn+xkTkdMxfnUizBl6MCAt0upSzY62tVa++fftacT8lJSV22LBhdtiwYbakpKSsPSkpydapU8f
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure()\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1]) # Large figure\n",
"axes2 = fig.add_axes([0.2, 0.5, 0.25, 0.25]) # Smaller figure\n",
"\n",
"# Larger Figure Axes 1\n",
"axes1.plot(a, b)\n",
"\n",
"# Use set_ to add to the axes figure\n",
"axes1.set_xlabel('X Label')\n",
"axes1.set_ylabel('Y Label')\n",
"axes1.set_title('Big Figure')\n",
"\n",
"# Insert Figure Axes 2\n",
"axes2.plot(a,b)\n",
"axes2.set_xlim(8,10)\n",
"axes2.set_ylim(4000,10000)\n",
"axes2.set_xlabel('X')\n",
"axes2.set_ylabel('Y')\n",
"axes2.set_title('Zoomed In');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add as many axes on to the same figure as you want, even outside of the main figure if the length and width correspond to this."
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x1cd42ad2888>]"
]
},
"execution_count": 74,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmAAAAGWCAYAAADfSD9JAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdeVzVVf7H8dcR3FdQUBARFHLNRsUl2zQHNSutxkyzxLT8jdVUzpY1VqNtVjO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c6cxxhpjKv0oUentjDGtjTEfG2OyjTHfGmOeMMascy0Lca3rXWrbtcaYO12fJxlj1htjnjfGZAB/dbVPNsbsMsZkGmNWGWM6nt+fioi4g7yCQt6LTWLki9+wLu4Qs0b14P9u70urJrVvaqHK0m+VIh7OGNMEuAWIKWf5COD3wFAgHvi/Kjr0y8BxoB0QAqwC9ldi+wHAYsAfqG+MuQF4GLgeiANmAO8Ag6qoXhGpJTKO5/NWzH6iN+7n0LE8ugW04F9REbV6ZPvKUgAT8VxLjTEFQDPgADC8nPXGAguttTsAjDGzgNvOse+5xpi/uT7vs9b2Kb3QGOMF/Aboaa3NAXYaY6KBwZWoP9Vae+q2aYEx5n+Ap621u1zHeAp42BjT0VpbmWAnIrXUfw4eY/66eP69JZm8giIGd/Hjzss7cVlYa4xxv472Z6MAJuK5brDWfu4KQ6OBr4wx3a21P5+xXiAQW+p7UgX2fZ+19l9nWe5H8f9fSu+rIvst7cz
"text/plain": [
"<Figure size 432x288 with 3 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure()\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1]) # Full figure\n",
"axes2 = fig.add_axes([0.2, 0.5, 0.25, 0.25]) # Smaller figure\n",
"axes3 = fig.add_axes([1, 1, 0.25, 0.25]) # Starts at top right corner!\n",
"\n",
"# Larger Figure Axes 1\n",
"axes1.plot(a, b)\n",
"\n",
"# Use set_ to add to the axes figure\n",
"axes1.set_xlabel('X Label')\n",
"axes1.set_ylabel('Y Label')\n",
"axes1.set_title('Big Figure')\n",
"\n",
"# Insert Figure Axes 2\n",
"axes2.plot(a,b)\n",
"axes2.set_xlim(8,10)\n",
"axes2.set_ylim(4000,10000)\n",
"axes2.set_xlabel('X')\n",
"axes2.set_ylabel('Y')\n",
"axes2.set_title('Zoomed In');\n",
"\n",
"# Insert Figure Axes 3\n",
"axes3.plot(a,b)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Figure Parameters"
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x1cd42d53848>]"
]
},
"execution_count": 82,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABPkAAANLCAYAAAAzfEjxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdaZSdd2Hn+d+/SvtSkowsyVpL3iLbAhu8yZKAE8CAB4xNs4Qtjq1JupNp6JMmmZAQ1pg0WXpIhpnkNM20ZGwwBAIYsxlDABNLtrxh8L7gKu2LLculfat65oWuQAjZluQqPXWrPp9z6pR17/9e/cpIvPie5/opVVUFAAAAAGheLXUPAAAAAABeGJEPAAAAAJqcyAcAAAAATU7kAwAAAIAmJ/IBAAAAQJMT+QAAAACgyYl8AAAAANDkhtQ9oE6llJJkapKtdW8BAAAAgGcxNsnaqqqqZzswqCNf9ge+1XWPAAAAAIDnMT3Jmmd7crBHvq1JsmrVqrS1tdW9BQAAAAB+zZYtWzJjxozkeT6JOtgjX5Kkra1N5AMAAACgabnxBgAAAAA0OZEPAAAAAJqcyAcAAAAATU7kAwAAAIAmJ/IBAAAAQJMT+QAAAACgyYl8AAAAANDkRD4AAAAAaHIiHwAAAAA0OZEPAAAAAJqcyAcAAAAATU7kAwAAAIAmJ/IBAAAAQJMT+QAAAACgyYl8AAAAANDkRD4AAAAAaHIiHwAAAAA0OZEPAAAAAJqcyAcAAAAATU7kAwAAAIAmJ/IBAAAAQJMT+QAAAACgyYl8AAAAANDkRD4AAAAAaHIiHwAAAAA0OZEPAAAAAJqcyAcAAAAATU7kAwAAAIAmJ/IBAAAAQJMT+QAAAACgyR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kWLZhd85rmI/IBAAAAULuv3r06W3fty8kTR+eVp59Y95ymI/IBAAAAUKuenirXLOtMkly5oD0tLaXeQU1I5AMAAACgVj9+dGM6ntqesSOG5C0vm173nKYk8gEAAABQq8W3diZJ3nnBzIwePqTeMU1K5AMAAACgNo9u2JpbH38qLSW54qJZdc9pWiIfAAAAALVZsrQjSfK6s6Zk+oRRNa9pXiIfAAAAALV4evuefO2eNUmSRQtn17ymuYl8AAAAANTii3eszO59PZk7rS3nzZpQ95ymJvIBAAAAcNzt7e7Jtbd1JkkWLZidUkqte5qdyAcAAADAcfed+9Zlw5bdOXHs8LzhJSfVPafpiXwAAAAAHHdLlnYmSd5z4awMH9Ja75gBQOQDAAAA4Li6Z+Xm3LvqmQxrbcm7582se86AIPIBAAAAcFwtvrUjSXLZOVMzcczwmtcMDCIfAAAAAMfNuq6d+e7965MkVy2YXfOagUPkAwAAAOC4ufa2FenuqTLv5BNy5tS2uucMGCIfAAAAAMfFzj3duX75yiSu4uttIh8AAAAAx8XXf7omXTv3ZsYJI/OaMybXPWdAEfkAAAAA6HNVVWXx0v033Lhy/uy0tpSaFw0sIh8AAAAAfe7fH3sqj2/cltHDWvO286bXPWfAEfkAAAAA6HNLGlfxve28GWkbMbTmNQOPyAcAAABAn/rFk9vyo0eeTCnJlfPb654zIIl8AAAAAPSpa5Z2JklePWdS2ieOrnfMACXyAQAAANBnunbszb/evTpJsmjB7JrXDFwiHwAAAAB95l/uWpmde7szZ8rYXHTKi+qeM2CJfAAAAAD0iX3dPfncshVJkqsWtKeUUvOigUvkAwAAAKBPfP/BDVnzzM6cMHpYLjtnWt1zBjSRDwAAAIA+sXhpR5Lk3RfOzIihrTWvGdhEPgAAAAB63X2ru3Jn5+YMaSl5z7xZdc8Z8EQ+AAAAAHrdksZVfG98yUm
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure(figsize=(12,8),dpi=100)\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1])\n",
"\n",
"axes1.plot(a,b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exporting a Figure"
]
},
{
"cell_type": "code",
"execution_count": 95,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeQAAAFNCAYAAADRvRzfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXxU9b3/8dcne8IWwk5CSBAEAUUwsluttOKOtbXF2srW0l+vvdrNXu2vLffqbWt7u9n+WnutgrhUtFSFWjeq1goIEhaVTYkkhBAggSRsIWSZ7++POWjAECTbOTPzfj4eecyc75wz82ZY3pwzZ87XnHOIiIiIv+L8DiAiIiIqZBERkUBQIYuIiASACllERCQAVMgiIiIBoEIWEREJgAS/A7RUz549XU5Ojt8xREREzsjatWv3Oed6nTwesYWck5NDfn6+3zFERETOiJntaGpch6xFREQCQIUsIiISACpkERGRAFAhi4iIBIAKWUREJABUyCIiIgGgQhYREQmA0xaymc03szIz29hoLMPMlpnZNu+2uzduZvZbMysws7fNbEyjbWZ4628zsxmNxi8ws3e8bX5rZtbWv0gREZGg+zh7yA8Bl580dgfwsnNuCPCytwxwBTDE+5kL3AfhAgfmAeOAscC84yXurTO30XYnv5aIiEjUO20hO+f+BVScNDwNWOjdXwhc12j8YRe2Ckg3s37AVGCZc67COVcJLAMu9x7r6px7wznngIcbPZeIiIiv6htCHfZaLf0MuY9zbjeAd9vbG88EdjZar8Qba268pIlxERER3819ZC3ff/qdDnmttj6pq6nPf10Lxpt+crO5ZpZvZvnl5eUtjCgiInJ6BWWHeWVrGX27pnTI67W0kPd6h5vxbsu88RJgQKP1soDS04xnNTHeJOfc/c65POdcXq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F073k2mdmThMu8HrjFOdfQ0lwiIhIbHlpRSFJ8HDeNj5w5j5vTqm9PO+fmAfNOGt5OE2dJO+dqgBtO8Tw/Bn7cmiwiIhI7Dhyt4y9rS7h6VD96d0nxO06b0JW6REQk4vwlfyfVtQ0ROavTqaiQRUQkojSEHA+tLGJsbgYjM7v5HafNqJBFRCSiLNu8l5LKo8yelON3lDalQhYRkYgyf0UhWd1T+fTwvn5HaVMqZBERiRgbdx3gzcIKZk7MIT4C5zxujgpZREQixoIVRaQlxXNDhM553BwVsoiIRISyQzX87a1Sbrggi26piX7HaXMqZBERiQiPrSqmtiHEzCj6qlNjKmQREQm8Y/UNPLZ6B5cO601uz05+x2kXKmQREQm8v721m32Ha6PqQiAnUyGLiEigOeeYv7yQs/t0ZtLgHn7HaTcqZBERCbQ3CyvYvPsgsyZF/pzHzVEhi4hIoM1fUUj3tEQ+MzrT7yjtSoUsIiKBtbOimpc27+WL47JJSYz8OY+bo0IWEZHAWriyiHgzvjw+x+8o7U6FLCIigXT4WD1PrNnJlef2o2+36JjzuDkqZBERCaTF+Ts5dKye2ZOj96tOjamQRUQkcELenMejs9M5f0C633E6hApZREQC59V3yyjaXx3VFwI5mQpZREQCZ/6KQvp1S+HykdE153FzVMgiIhIo7+45xIqC/Xx5wkAS42OnpmLnVyoiIhFhwYpCUhLjuPHCbL+jdCgVsoiIBEbFkVqeXr+L68dk0b1Tkt9xOpQKWUREAuPxN4s5Vh9i1sQcv6N0OBWyiIgEQm19iIffKOKiIT0Z0qeL33E6nApZREQC4fmNu9l78FjMXAjkZCpkERHx3fE5jwf17MTFQ3r5HccXKmQREfHduuIq3io5wKxJOcTFRe+cx81RIYuIiO/mryi
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1])\n",
"\n",
"axes1.plot(a,b)\n",
"axes1.set_xlabel('X')\n",
"\n",
"# bbox_inches ='tight' automatically makes sure the bounding box is correct\n",
"fig.savefig('figure.png',bbox_inches='tight')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "code",
"execution_count": 112,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABGMAAALvCAYAAADBDwidAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdf8zud13f8dfntDoHSrQUEEpvDxiis2TF7U5bRuaqTMCO2Tmqg6mg0x01suGiGdUlw1WyGFCRBCceoSAZlBJpJ6kEaNzcYUvUc4o/ChYBsbaH01EqHq16jLZ974/7Jly9z/37+vH99Xgkzbnv6/qe6/pASAgvntf3alUVAAAAAFbjSNcHAAAAAJgSYwwAAADAChljAAAAAFbIGAMAAACwQsYYAAAAgBUyxgAAAACs0IVdHwAAAIDuXHzxxXX06NGujwGjdMcddzxQVU/Y+rgxBgAAYMKOHj2aU6dOdX0MGKXW2h9v97iPKQEAAACskDEGAAAAYIWMMQAAAAArZIwBAAAA2Ieqys0n78ndD/zlXK9jjAEAAADYw5mz5/Kyt5zMK999Z97+m9vel3fffJsSAAAAwA6qKu86dW9efdtdeeiRyg3XXpbvuPIr5npNYwwAAADANs6cPZfrb7kzJz72mVz5tIvy2usuz9rjHzP36xpjAAAAAGbsVMMcOdIW8vrGGAAAAIBNy6phZhljAAAAgMlbdg0zyxgDAAAATNoqaphZxhgAAABgklZZw8wyxgAAAACTs+oaZpYxBgAAAJiMrmqYWcYYAAAAYBK6rGFmGWMAAACAUetDDTPLGAMAAACMVl9qmFnGGAAAAGB0+lbDzDLGAAAAAKPSxxpmljEGAAAAGIXZGubhqvyXb74s33lVP2qYWcYYAAAAYPBma5irnn5RXvOiftUws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IDcMwGGMAAAAYFDUMQ2eMAQAAYDDUMIyBMQYAAIDeU8MwJsYYAAAAek0Nw9gYYwAAAOglNQxjZYwBAACgd9QwjJkxBgAAgN5QwzAFxhgAAAB6QQ3DVBhjAAAA6JQahqkxxgAAANAZNQxTZIwBAABg5dQwTJkxBgAAgJVSwzB1xhgAAABWQg0DG4wxAAAALJ0aBj7PGAMAAMDSqGHgfMYYAAAAlkINA9szxgAAALBQahjYnTEGAACAhVHDwN6MMQAAAMxNDQP7Z4wBAABgLmoYOBhjDAAAAIeytYb5iWsvy7erYWBPxhgAAAAObGsN89rrLs+lF6lhYD+MMQAAAOybGgbmZ4wBAAAYkdbaC5K8PskFSd5UVT+5qNdWw8BiGGMAAABGorV2QZKfS/KNSU4nOdlae09V/f48r6uGgcUyxgAAAIzHFUk+UVWfTJLW2juTXJvk0GOMGgYWzxgDAAAwHpckuXfm99NJrtx6UWvtWJJjSbK2trbrC568+7M5dfdn1TCwQMYYAACA8dhuKanzHqg6nuR4kqyvr5/3/KxvvvwpefZXPj5P/JIvWswJgRzp+gAAAAAszOkkl878/tQkZ+Z5wdaaIQYWzBgDAAAwHieTPKO19rTW2hcmeXGS93R8JmALH1MCAAAYiap6qLX28iTvz8ZXW99YVR/p+FjAFsYYAACAEamq9yZ5b9fnAHbmY0oAAAAAK9TLMubiiy+uo0ePdn0MAACA0bvjjjuqtfahPS67OMkDqzjPgjjv8gzprEn35/2K7R7s5Rhz9OjRnDp1qutjAAAAjF5r7UNVtb7HNaf2uqZPnHd5hnTWpL/n9TElAAAAgBUyxgAAAACskDEGAACAvRzv+gAH5LzLM6SzJj09b6uqrs9wnvX19XLPGAAAgOVrrd3Rx3tqwJgpYwAAAABWyBgDAADAjlprL2it/UFr7ROtteu7Ps9uWmuXttb+V2vtrtb
"text/plain": [
"<Figure size 864x576 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Creates blank canvas\n",
"fig = plt.figure(figsize=(12,8))\n",
"\n",
"axes1 = fig.add_axes([0, 0, 1, 1]) # Full figure\n",
"axes2 = fig.add_axes([1, 1, 0.25, 0.25]) # Starts at top right corner!\n",
"\n",
"# Larger Figure Axes 1\n",
"axes1.plot(x,y)\n",
"\n",
"# Insert Figure Axes 2\n",
"axes2.plot(x,y)\n",
"\n",
"fig.savefig('test.png',bbox_inches='tight')"
]
},
{
"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.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}