
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples\matplotlib\artist_tests.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        Click :ref:`here <sphx_glr_download_auto_examples_matplotlib_artist_tests.py>`
        to download the full example code

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

.. _sphx_glr_auto_examples_matplotlib_artist_tests.py:


============
Artist tests
============

Test unit support with each of the Matplotlib primitive artist types.

The axis handles unit conversions and the artists keep a pointer to their axis
parent. You must initialize the artists with the axis instance if you want to
use them with unit data, or else they will not know how to convert the units
to scalars.

.. only:: builder_html

   This example requires :download:`basic_units.py <basic_units.py>`

.. GENERATED FROM PYTHON SOURCE LINES 17-35



.. image-sg:: /auto_examples/matplotlib/images/sphx_glr_artist_tests_001.png
   :alt: artist tests
   :srcset: /auto_examples/matplotlib/images/sphx_glr_artist_tests_001.png
   :class: sphx-glr-single-img





.. code-block:: default

    import random
    import matplotlib.lines as lines
    import matplotlib.patches as patches
    import matplotlib.text as text
    import matplotlib.collections as collections

    #from basic_units import cm, inch
    import numpy as np
    import matplotlib.pyplot as plt

    fig, ax = plt.subplots()
    # test a plain-ol-line
    line = lines.Line2D([0, 0.5], [0, 1],
                        lw=2, color='r',
                        transform=ax.transAxes)
    ax.add_line(line)

    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.040 seconds)


.. _sphx_glr_download_auto_examples_matplotlib_artist_tests.py:

.. only:: html

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


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

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

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

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


.. only:: html

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

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