{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Parasite Axes demo\n\nCreate a parasite Axes. Such Axes would share the x scale with a host Axes,\nbut show a different scale in y direction.\n\nThis approach uses `mpl_toolkits.axes_grid1.parasite_axes.HostAxes` and\n`mpl_toolkits.axes_grid1.parasite_axes.ParasiteAxes`.\n\nThe standard and recommended approach is to use instead standard Matplotlib\naxes, as shown in the\n:doc:`/gallery/subplots_axes_and_figures/multiple_yaxis_with_spines` example.\n\nAn alternative approach using `mpl_toolkits.axes_grid1` and\n`mpl_toolkits.axisartist` is shown in the\n:doc:`/gallery/axisartist/demo_parasite_axes2` example.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom mpl_toolkits.axisartist.parasite_axes import HostAxes\n\nfig = plt.figure()\n\nhost = fig.add_axes((0.15, 0.1, 0.65, 0.8), axes_class=HostAxes)\npar1 = host.get_aux_axes(viewlim_mode=None, sharex=host)\npar2 = host.get_aux_axes(viewlim_mode=None, sharex=host)\n\nhost.axis[\"right\"].set_visible(False)\n\npar1.axis[\"right\"].set_visible(True)\npar1.axis[\"right\"].major_ticklabels.set_visible(True)\npar1.axis[\"right\"].label.set_visible(True)\n\npar2.axis[\"right2\"] = par2.new_fixed_axis(loc=\"right\", offset=(60, 0))\n\np1, = host.plot([0, 1, 2], [0, 1, 2], label=\"Density\")\np2, = par1.plot([0, 1, 2], [0, 3, 2], label=\"Temperature\")\np3, = par2.plot([0, 1, 2], [50, 30, 15], label=\"Velocity\")\n\nhost.set(xlim=(0, 2), ylim=(0, 2), xlabel=\"Distance\", ylabel=\"Density\")\npar1.set(ylim=(0, 4), ylabel=\"Temperature\")\npar2.set(ylim=(1, 65), ylabel=\"Velocity\")\n\nhost.legend()\n\nhost.axis[\"left\"].label.set_color(p1.get_color())\npar1.axis[\"right\"].label.set_color(p2.get_color())\npar2.axis[\"right2\"].label.set_color(p3.get_color())\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
}