
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/userdemo/simple_legend01.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_userdemo_simple_legend01.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_userdemo_simple_legend01.py:


===============
Simple Legend01
===============

.. GENERATED FROM PYTHON SOURCE LINES 7-26



.. image-sg:: /gallery/userdemo/images/sphx_glr_simple_legend01_001.png
   :alt: simple legend01
   :srcset: /gallery/userdemo/images/sphx_glr_simple_legend01_001.png, /gallery/userdemo/images/sphx_glr_simple_legend01_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python

    import matplotlib.pyplot as plt

    fig = plt.figure()

    ax = fig.add_subplot(211)
    ax.plot([1, 2, 3], label="test1")
    ax.plot([3, 2, 1], label="test2")
    # Place a legend above this subplot, expanding itself to
    # fully use the given bounding box.
    ax.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',
               ncols=2, mode="expand", borderaxespad=0.)

    ax = fig.add_subplot(223)
    ax.plot([1, 2, 3], label="test1")
    ax.plot([3, 2, 1], label="test2")
    # Place a legend to the right of this smaller subplot.
    ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)

    plt.show()


.. _sphx_glr_download_gallery_userdemo_simple_legend01.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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