{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# HBoxDivider and VBoxDivider demo\n\nUsing an `.HBoxDivider` to arrange subplots.\n\nNote that both Axes' location are adjusted so that they have\nequal heights while maintaining their aspect ratios.\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.axes_divider import HBoxDivider, VBoxDivider\nimport mpl_toolkits.axes_grid1.axes_size as Size\n\narr1 = np.arange(20).reshape((4, 5))\narr2 = np.arange(20).reshape((5, 4))\n\nfig, (ax1, ax2) = plt.subplots(1, 2)\nax1.imshow(arr1)\nax2.imshow(arr2)\n\npad = 0.5  # pad in inches\ndivider = HBoxDivider(\n    fig, 111,\n    horizontal=[Size.AxesX(ax1), Size.Fixed(pad), Size.AxesX(ax2)],\n    vertical=[Size.AxesY(ax1), Size.Scaled(1), Size.AxesY(ax2)])\nax1.set_axes_locator(divider.new_locator(0))\nax2.set_axes_locator(divider.new_locator(2))\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Using a `.VBoxDivider` to arrange subplots.\n\nNote that both Axes' location are adjusted so that they have\nequal widths while maintaining their aspect ratios.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig, (ax1, ax2) = plt.subplots(2, 1)\nax1.imshow(arr1)\nax2.imshow(arr2)\n\ndivider = VBoxDivider(\n    fig, 111,\n    horizontal=[Size.AxesX(ax1), Size.Scaled(1), Size.AxesX(ax2)],\n    vertical=[Size.AxesY(ax1), Size.Fixed(pad), Size.AxesY(ax2)])\n\nax1.set_axes_locator(divider.new_locator(0))\nax2.set_axes_locator(divider.new_locator(2))\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.14.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}