
.. 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

    .. meta::
        :keywords: codex

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

        :ref:`Go to the end <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:


================================
Annotation arrow style reference
================================

Overview of the available `.ArrowStyle` settings. These are used for the *arrowstyle*
parameter of `~.Axes.annotate` and `.FancyArrowPatch`.

Each style can be configured with a set of parameters, which are stated along with
their default values.

.. GENERATED FROM PYTHON SOURCE LINES 12-54

.. code-block:: Python


    import inspect
    import itertools
    import re

    import matplotlib.pyplot as plt

    from matplotlib.patches import ArrowStyle

    styles = ArrowStyle.get_styles()
    ncol = 2
    nrow = (len(styles) + 1) // ncol
    gridspec_kw = dict(wspace=0, hspace=0.05, left=0, right=1, bottom=0, top=1)
    fig, axs = plt.subplots(1 + nrow, ncol,
                            figsize=(4 * ncol, 1 + nrow), gridspec_kw=gridspec_kw)
    for ax in axs.flat:
        ax.set_xlim(-0.1, 4)
        ax.set_axis_off()
    for ax in axs[0, :]:
        ax.text(0, 0.5, "arrowstyle", size="large", color="tab:blue")
        ax.text(1.4, .5, "default parameters", size="large")
    for ax, (stylename, stylecls) in zip(axs[1:, :].T.flat, styles.items()):
        # draw dot and annotation with arrowstyle
        l, = ax.plot(1.25, 0, "o", color="darkgrey")
        ax.annotate(stylename, (1.25, 0), (0, 0),
                    size="large", color="tab:blue", va="center", family="monospace",
                    arrowprops=dict(
                        arrowstyle=stylename, connectionstyle="arc3,rad=0",
                        color="black", shrinkA=5, shrinkB=5, patchB=l,
                    ),
                    bbox=dict(boxstyle="square", fc="w", ec="darkgrey"))
        # draw default parameters
        # wrap at every nth comma (n = 1 or 2, depending on text length)
        s = str(inspect.signature(stylecls))[1:-1]
        n = 2 if s.count(',') > 3 else 1
        ax.text(1.4, 0,
                re.sub(', ', lambda m, c=itertools.count(1): m.group()
                       if next(c) % n else '\n', s),
                verticalalignment="center", color="0.3")

    plt.show()




.. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001.png
   :alt: fancyarrow demo
   :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_fancyarrow_demo_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 55-64

.. admonition:: References

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

   - `matplotlib.patches`
   - `matplotlib.patches.ArrowStyle`
   - ``matplotlib.patches.ArrowStyle.get_styles``
   - `matplotlib.axes.Axes.annotate`


.. _sphx_glr_download_gallery_text_labels_and_annotations_fancyarrow_demo.py:

.. only:: html

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

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

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

    .. 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-zip

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


.. only:: html

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

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