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

.. only:: html

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

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

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

.. _sphx_glr_gallery_userdemo_annotate_explain.py:


================
Annotate Explain
================

.. GENERATED FROM PYTHON SOURCE LINES 7-84



.. image:: /gallery/userdemo/images/sphx_glr_annotate_explain_001.png
    :alt: annotate explain
    :class: sphx-glr-single-img





.. code-block:: default


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


    fig, axs = plt.subplots(2, 2)
    x1, y1 = 0.3, 0.3
    x2, y2 = 0.7, 0.7

    ax = axs.flat[0]
    ax.plot([x1, x2], [y1, y2], ".")
    el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
    ax.add_artist(el)
    ax.annotate("",
                xy=(x1, y1), xycoords='data',
                xytext=(x2, y2), textcoords='data',
                arrowprops=dict(arrowstyle="-",
                                color="0.5",
                                patchB=None,
                                shrinkB=0,
                                connectionstyle="arc3,rad=0.3",
                                ),
                )
    ax.text(.05, .95, "connect", transform=ax.transAxes, ha="left", va="top")

    ax = axs.flat[1]
    ax.plot([x1, x2], [y1, y2], ".")
    el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
    ax.add_artist(el)
    ax.annotate("",
                xy=(x1, y1), xycoords='data',
                xytext=(x2, y2), textcoords='data',
                arrowprops=dict(arrowstyle="-",
                                color="0.5",
                                patchB=el,
                                shrinkB=0,
                                connectionstyle="arc3,rad=0.3",
                                ),
                )
    ax.text(.05, .95, "clip", transform=ax.transAxes, ha="left", va="top")

    ax = axs.flat[2]
    ax.plot([x1, x2], [y1, y2], ".")
    el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
    ax.add_artist(el)
    ax.annotate("",
                xy=(x1, y1), xycoords='data',
                xytext=(x2, y2), textcoords='data',
                arrowprops=dict(arrowstyle="-",
                                color="0.5",
                                patchB=el,
                                shrinkB=5,
                                connectionstyle="arc3,rad=0.3",
                                ),
                )
    ax.text(.05, .95, "shrink", transform=ax.transAxes, ha="left", va="top")

    ax = axs.flat[3]
    ax.plot([x1, x2], [y1, y2], ".")
    el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
    ax.add_artist(el)
    ax.annotate("",
                xy=(x1, y1), xycoords='data',
                xytext=(x2, y2), textcoords='data',
                arrowprops=dict(arrowstyle="fancy",
                                color="0.5",
                                patchB=el,
                                shrinkB=5,
                                connectionstyle="arc3,rad=0.3",
                                ),
                )
    ax.text(.05, .95, "mutate", transform=ax.transAxes, ha="left", va="top")

    for ax in axs.flat:
        ax.set(xlim=(0, 1), ylim=(0, 1), xticks=[], yticks=[], aspect=1)

    plt.show()


.. _sphx_glr_download_gallery_userdemo_annotate_explain.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: annotate_explain.py <annotate_explain.py>`



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

     :download:`Download Jupyter notebook: annotate_explain.ipynb <annotate_explain.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>`_
