{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Annotation arrow style reference\n\nOverview of the available `.ArrowStyle` settings. These are used for the *arrowstyle*\nparameter of `~.Axes.annotate` and `.FancyArrowPatch`.\n\nEach style can be configured with a set of parameters, which are stated along with\ntheir default values.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import inspect\nimport itertools\nimport re\n\nimport matplotlib.pyplot as plt\n\nfrom matplotlib.patches import ArrowStyle\n\nstyles = ArrowStyle.get_styles()\nncol = 2\nnrow = (len(styles) + 1) // ncol\ngridspec_kw = dict(wspace=0, hspace=0.05, left=0, right=1, bottom=0, top=1)\nfig, axs = plt.subplots(1 + nrow, ncol,\n                        figsize=(4 * ncol, 1 + nrow), gridspec_kw=gridspec_kw)\nfor ax in axs.flat:\n    ax.set_xlim(-0.1, 4)\n    ax.set_axis_off()\nfor ax in axs[0, :]:\n    ax.text(0, 0.5, \"arrowstyle\", size=\"large\", color=\"tab:blue\")\n    ax.text(1.4, .5, \"default parameters\", size=\"large\")\nfor ax, (stylename, stylecls) in zip(axs[1:, :].T.flat, styles.items()):\n    # draw dot and annotation with arrowstyle\n    l, = ax.plot(1.25, 0, \"o\", color=\"darkgrey\")\n    ax.annotate(stylename, (1.25, 0), (0, 0),\n                size=\"large\", color=\"tab:blue\", va=\"center\", family=\"monospace\",\n                arrowprops=dict(\n                    arrowstyle=stylename, connectionstyle=\"arc3,rad=0\",\n                    color=\"black\", shrinkA=5, shrinkB=5, patchB=l,\n                ),\n                bbox=dict(boxstyle=\"square\", fc=\"w\", ec=\"darkgrey\"))\n    # draw default parameters\n    # wrap at every nth comma (n = 1 or 2, depending on text length)\n    s = str(inspect.signature(stylecls))[1:-1]\n    n = 2 if s.count(',') > 3 else 1\n    ax.text(1.4, 0,\n            re.sub(', ', lambda m, c=itertools.count(1): m.group()\n                   if next(c) % n else '\\n', s),\n            verticalalignment=\"center\", color=\"0.3\")\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.patches`\n   - `matplotlib.patches.ArrowStyle`\n   - ``matplotlib.patches.ArrowStyle.get_styles``\n   - `matplotlib.axes.Axes.annotate`\n\n"
      ]
    }
  ],
  "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
}