.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/pyplots/fig_x.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_pyplots_fig_x.py: ======================= Adding lines to figures ======================= Adding lines to a figure without any axes. .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. code-block:: default import matplotlib.pyplot as plt import matplotlib.lines as lines fig = plt.figure() fig.add_artist(lines.Line2D([0, 1], [0, 1])) fig.add_artist(lines.Line2D([0, 1], [1, 0])) plt.show() .. image:: /gallery/pyplots/images/sphx_glr_fig_x_001.png :alt: fig x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 19-27 .. 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_pyplots_fig_x.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fig_x.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fig_x.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_