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

.. only:: html

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

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

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

.. _sphx_glr_gallery_text_labels_and_annotations_fancyarrow_demo.py:


===============
Fancyarrow Demo
===============

.. GENERATED FROM PYTHON SOURCE LINES 7-56

.. code-block:: default

    import matplotlib.patches as mpatches
    import matplotlib.pyplot as plt

    styles = mpatches.ArrowStyle.get_styles()

    ncol = 2
    nrow = (len(styles) + 1) // ncol
    figheight = (nrow + 0.5)
    fig = plt.figure(figsize=(4 * ncol / 1.5, figheight / 1.5))
    fontsize = 0.2 * 70


    ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1.)

    ax.set_xlim(0, 4 * ncol)
    ax.set_ylim(0, figheight)


    def to_texstring(s):
        s = s.replace("<", r"$<$")
        s = s.replace(">", r"$>$")
        s = s.replace("|", r"$|$")
        return s


    for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
        x = 3.2 + (i // nrow) * 4
        y = (figheight - 0.7 - i % nrow)  # /figheight
        p = mpatches.Circle((x, y), 0.2)
        ax.add_patch(p)

        ax.annotate(to_texstring(stylename), (x, y),
                    (x - 1.2, y),
                    ha="right", va="center",
                    size=fontsize,
                    arrowprops=dict(arrowstyle=stylename,
                                    patchB=p,
                                    shrinkA=5,
                                    shrinkB=5,
                                    fc="k", ec="k",
                                    connectionstyle="arc3,rad=-0.05",
                                    ),
                    bbox=dict(boxstyle="square", fc="w"))

    ax.xaxis.set_visible(False)
    ax.yaxis.set_visible(False)

    plt.show()




.. image:: /gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001.png
    :alt: fancyarrow demo
    :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 57-64

------------

References
""""""""""

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

.. GENERATED FROM PYTHON SOURCE LINES 65-71

.. code-block:: default


    import matplotlib
    matplotlib.patches
    matplotlib.patches.ArrowStyle
    matplotlib.patches.ArrowStyle.get_styles
    matplotlib.axes.Axes.annotate




.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    <function Axes.annotate at 0x7f73be8ef670>




.. _sphx_glr_download_gallery_text_labels_and_annotations_fancyarrow_demo.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: fancyarrow_demo.py <fancyarrow_demo.py>`



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

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
