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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_examples_nondraggable.py>`
        to download the full example code.

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

.. _sphx_glr_examples_nondraggable.py:


Using multiple annotations and disabling draggability via signals
=================================================================

By default, each `Cursor` will ever display one annotation at a time.  Pass
``multiple=True`` to display multiple annotations.

Annotations can be made non-draggable by hooking their creation.

.. GENERATED FROM PYTHON SOURCE LINES 10-25



.. image-sg:: /examples/images/sphx_glr_nondraggable_001.png
   :alt: Multiple non-draggable annotations
   :srcset: /examples/images/sphx_glr_nondraggable_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np
    import mplcursors

    data = np.outer(range(10), range(1, 5))

    fig, ax = plt.subplots()
    ax.set_title("Multiple non-draggable annotations")
    ax.plot(data)

    mplcursors.cursor(multiple=True).connect(
        "add", lambda sel: sel.annotation.draggable(False))

    plt.show()


.. _sphx_glr_download_examples_nondraggable.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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