{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Simple ImageGrid\n\nAlign multiple images using `~mpl_toolkits.axes_grid1.axes_grid.ImageGrid`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom mpl_toolkits.axes_grid1 import ImageGrid\n\nim1 = np.arange(100).reshape((10, 10))\nim2 = im1.T\nim3 = np.flipud(im1)\nim4 = np.fliplr(im2)\n\nfig = plt.figure(figsize=(4., 4.))\ngrid = ImageGrid(fig, 111, # similar to subplot(111)\n nrows_ncols=(2, 2), # creates 2x2 grid of Axes\n axes_pad=0.1, # pad between Axes in inch.\n )\n\nfor ax, im in zip(grid, [im1, im2, im3, im4]):\n # Iterating over the grid returns the Axes.\n ax.imshow(im)\n\nplt.show()" ] } ], "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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }