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

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

.. _sphx_glr_gallery_misc_fig_x.py:


==============================
Add lines directly to a figure
==============================

You can add artists such as a `.Line2D` directly to a figure. This is
typically useful for visual structuring.

.. redirect-from:: /gallery/pyplots/fig_x

.. GENERATED FROM PYTHON SOURCE LINES 11-21

.. code-block:: Python


    import matplotlib.pyplot as plt

    import matplotlib.lines as lines

    fig, axs = plt.subplots(2, 2, gridspec_kw={'hspace': 0.4, 'wspace': 0.4})
    fig.add_artist(lines.Line2D([0, 1], [0.47, 0.47], linewidth=3))
    fig.add_artist(lines.Line2D([0.5, 0.5], [1, 0], linewidth=3))
    plt.show()




.. image-sg:: /gallery/misc/images/sphx_glr_fig_x_001.png
   :alt: fig x
   :srcset: /gallery/misc/images/sphx_glr_fig_x_001.png, /gallery/misc/images/sphx_glr_fig_x_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 22-30

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.pyplot.figure`
   - `matplotlib.lines`
   - `matplotlib.lines.Line2D`


.. _sphx_glr_download_gallery_misc_fig_x.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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