{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Shared axis\n\nUse axis sharing when you want to compare data across multiple subplots, and want to\nensure they are on the same scale. To do so, pass ``sharex=True`` and/or ``sharey=True``\nto `~.pyplot.subplots`.\n\nThis ensures the x- or y-axis limits are synchronized across the subplots. Autoscaling\nconsiders the data on all Axes; therefore, any limit changes, including interactive zoom\nand pan, will affect all shared axes.\n\nThe plot below illustrates this by showing two different time-series and using *sharex*\nto ensure the times are aligned.\n\nFor more info see `sharing-axes`.\n\n.. redirect-from:: /gallery/subplots_axes_and_figures/share_axis_lims_views\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nt1 = np.linspace(0, 8, 201)\ny1 = np.sin(2 * np.pi * t1)\nt2 = np.linspace(2, 10, 201)\ny2 = 20 * np.cos(2 * np.pi * t2)**2 * np.exp(-0.3*t2)\n\nfig, (ax1, ax2) = plt.subplots(2, sharex=True)\n\nax1.plot(t1, y1)\nax1.set_ylabel(\"Signal 1\")\n\nax2.plot(t2, y2)\nax2.set_ylabel(\"Signal 2\")\nax2.set_xlabel(\"Time (s)\")\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n\n   component: axis\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.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}