{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Pan/zoom events of overlapping axes\n\nExample to illustrate how pan/zoom events of overlapping axes are treated.\n\n\nThe default is the following:\n\n- Axes with a visible patch capture pan/zoom events\n- Axes with an invisible patch forward pan/zoom events to axes below\n- Shared axes always trigger with their parent axes\n  (irrespective of the patch visibility)\n\nNote: The visibility of the patch hereby refers to the value of\n``ax.patch.get_visible()``. The color and transparency of a\npatch have no effect on the treatment of pan/zoom events!\n\n\n``ax.set_forward_navigation_events(val)`` can be used to override the\ndefault behaviour:\n\n- ``True``:  Forward navigation events to axes below.\n- ``False``: Execute navigation events only on this axes.\n- ``\"auto\"``: Use the default behaviour.\n\nTo disable pan/zoom events completely, use ``ax.set_navigate(False)``\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfig = plt.figure(figsize=(11, 6))\nfig.suptitle(\"Showcase for pan/zoom events on overlapping axes.\")\n\nax = fig.add_axes((.05, .05, .9, .9))\nax.patch.set_color(\".75\")\nax_twin = ax.twinx()\n\nax1 = fig.add_subplot(221)\nax1_twin = ax1.twinx()\nax1.text(.5, .5,\n         \"Visible patch\\n\\n\"\n         \"Pan/zoom events are NOT\\n\"\n         \"forwarded to axes below\",\n         ha=\"center\", va=\"center\", transform=ax1.transAxes)\n\nax11 = fig.add_subplot(223, sharex=ax1, sharey=ax1)\nax11.set_forward_navigation_events(True)\nax11.text(.5, .5,\n          \"Visible patch\\n\\n\"\n          \"Override capture behavior:\\n\\n\"\n          \"ax.set_forward_navigation_events(True)\",\n          ha=\"center\", va=\"center\", transform=ax11.transAxes)\n\nax2 = fig.add_subplot(222)\nax2_twin = ax2.twinx()\nax2.patch.set_visible(False)\nax2.text(.5, .5,\n         \"Invisible patch\\n\\n\"\n         \"Pan/zoom events are\\n\"\n         \"forwarded to axes below\",\n         ha=\"center\", va=\"center\", transform=ax2.transAxes)\n\nax22 = fig.add_subplot(224, sharex=ax2, sharey=ax2)\nax22.patch.set_visible(False)\nax22.set_forward_navigation_events(False)\nax22.text(.5, .5,\n          \"Invisible patch\\n\\n\"\n          \"Override capture behavior:\\n\\n\"\n          \"ax.set_forward_navigation_events(False)\",\n          ha=\"center\", va=\"center\", transform=ax22.transAxes)"
      ]
    }
  ],
  "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
}