{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Adjacent subplots\n\nTo create plots that share a common axis (visually) you can set the hspace\nbetween the subplots to zero. Passing sharex=True when creating the subplots\nwill automatically turn off all x ticks and labels except those on the bottom\naxis.\n\nIn this example the plots share a common x-axis, but you can follow the same\nlogic to supply a common y-axis.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nt = np.arange(0.0, 2.0, 0.01)\n\ns1 = np.sin(2 * np.pi * t)\ns2 = np.exp(-t)\ns3 = s1 * s2\n\nfig, axs = plt.subplots(3, 1, sharex=True)\n# Remove vertical space between Axes\nfig.subplots_adjust(hspace=0)\n\n# Plot each graph, and manually set the y tick values\naxs[0].plot(t, s1)\naxs[0].set_yticks(np.arange(-0.9, 1.0, 0.4))\naxs[0].set_ylim(-1, 1)\n\naxs[1].plot(t, s2)\naxs[1].set_yticks(np.arange(0.1, 1.0, 0.2))\naxs[1].set_ylim(0, 1)\n\naxs[2].plot(t, s3)\naxs[2].set_yticks(np.arange(-0.9, 1.0, 0.4))\naxs[2].set_ylim(-1, 1)\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n\n   component: subplot\n   plot-type: line\n   level: beginner\n\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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}