
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/axes_grid1/parasite_simple.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_axes_grid1_parasite_simple.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_axes_grid1_parasite_simple.py:


===============
Parasite Simple
===============

.. GENERATED FROM PYTHON SOURCE LINES 6-27

.. code-block:: Python


    import matplotlib.pyplot as plt

    from mpl_toolkits.axes_grid1 import host_subplot

    host = host_subplot(111)
    par = host.twinx()

    host.set_xlabel("Distance")
    host.set_ylabel("Density")
    par.set_ylabel("Temperature")

    p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
    p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature")

    host.legend(labelcolor="linecolor")

    host.yaxis.label.set_color(p1.get_color())
    par.yaxis.label.set_color(p2.get_color())

    plt.show()


.. _sphx_glr_download_gallery_axes_grid1_parasite_simple.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: parasite_simple.ipynb <parasite_simple.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: parasite_simple.py <parasite_simple.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: parasite_simple.zip <parasite_simple.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
