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

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

.. _sphx_glr_gallery_axes_grid1_demo_anchored_direction_arrows.py:


========================
Anchored Direction Arrow
========================

.. GENERATED FROM PYTHON SOURCE LINES 7-83

.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    import matplotlib.font_manager as fm
    from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows

    # Fixing random state for reproducibility
    np.random.seed(19680801)

    fig, ax = plt.subplots()
    ax.imshow(np.random.random((10, 10)))

    # Simple example
    simple_arrow = AnchoredDirectionArrows(ax.transAxes, 'X', 'Y')
    ax.add_artist(simple_arrow)

    # High contrast arrow
    high_contrast_part_1 = AnchoredDirectionArrows(
                                ax.transAxes,
                                '111', r'11$\overline{2}$',
                                loc='upper right',
                                arrow_props={'ec': 'w', 'fc': 'none', 'alpha': 1,
                                             'lw': 2}
                                )
    ax.add_artist(high_contrast_part_1)

    high_contrast_part_2 = AnchoredDirectionArrows(
                                ax.transAxes,
                                '111', r'11$\overline{2}$',
                                loc='upper right',
                                arrow_props={'ec': 'none', 'fc': 'k'},
                                text_props={'ec': 'w', 'fc': 'k', 'lw': 0.4}
                                )
    ax.add_artist(high_contrast_part_2)

    # Rotated arrow
    fontprops = fm.FontProperties(family='serif')

    rotated_arrow = AnchoredDirectionArrows(
                        ax.transAxes,
                        '30', '120',
                        loc='center',
                        color='w',
                        angle=30,
                        fontproperties=fontprops
                        )
    ax.add_artist(rotated_arrow)

    # Altering arrow directions
    a1 = AnchoredDirectionArrows(
            ax.transAxes, 'A', 'B', loc='lower center',
            length=-0.15,
            sep_x=0.03, sep_y=0.03,
            color='r'
        )
    ax.add_artist(a1)

    a2 = AnchoredDirectionArrows(
            ax.transAxes, 'A', ' B', loc='lower left',
            aspect_ratio=-1,
            sep_x=0.01, sep_y=-0.02,
            color='orange'
            )
    ax.add_artist(a2)


    a3 = AnchoredDirectionArrows(
            ax.transAxes, ' A', 'B', loc='lower right',
            length=-0.15,
            aspect_ratio=-1,
            sep_y=-0.1, sep_x=0.04,
            color='cyan'
            )
    ax.add_artist(a3)

    plt.show()


.. _sphx_glr_download_gallery_axes_grid1_demo_anchored_direction_arrows.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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