{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Anchored Direction Arrow\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport matplotlib.font_manager as fm\nfrom mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\nfig, ax = plt.subplots()\nax.imshow(np.random.random((10, 10)))\n\n# Simple example\nsimple_arrow = AnchoredDirectionArrows(ax.transAxes, 'X', 'Y')\nax.add_artist(simple_arrow)\n\n# High contrast arrow\nhigh_contrast_part_1 = AnchoredDirectionArrows(\n                            ax.transAxes,\n                            '111', r'11$\\overline{2}$',\n                            loc='upper right',\n                            arrow_props={'ec': 'w', 'fc': 'none', 'alpha': 1,\n                                         'lw': 2}\n                            )\nax.add_artist(high_contrast_part_1)\n\nhigh_contrast_part_2 = AnchoredDirectionArrows(\n                            ax.transAxes,\n                            '111', r'11$\\overline{2}$',\n                            loc='upper right',\n                            arrow_props={'ec': 'none', 'fc': 'k'},\n                            text_props={'ec': 'w', 'fc': 'k', 'lw': 0.4}\n                            )\nax.add_artist(high_contrast_part_2)\n\n# Rotated arrow\nfontprops = fm.FontProperties(family='serif')\n\nrotated_arrow = AnchoredDirectionArrows(\n                    ax.transAxes,\n                    '30', '120',\n                    loc='center',\n                    color='w',\n                    angle=30,\n                    fontproperties=fontprops\n                    )\nax.add_artist(rotated_arrow)\n\n# Altering arrow directions\na1 = AnchoredDirectionArrows(\n        ax.transAxes, 'A', 'B', loc='lower center',\n        length=-0.15,\n        sep_x=0.03, sep_y=0.03,\n        color='r'\n    )\nax.add_artist(a1)\n\na2 = AnchoredDirectionArrows(\n        ax.transAxes, 'A', ' B', loc='lower left',\n        aspect_ratio=-1,\n        sep_x=0.01, sep_y=-0.02,\n        color='orange'\n        )\nax.add_artist(a2)\n\n\na3 = AnchoredDirectionArrows(\n        ax.transAxes, ' A', 'B', loc='lower right',\n        length=-0.15,\n        aspect_ratio=-1,\n        sep_y=-0.1, sep_x=0.04,\n        color='cyan'\n        )\nax.add_artist(a3)\n\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}