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

    Click :ref:`here <sphx_glr_download_examples_hover.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_hover.py:


Annotate on hover
=================

When ``hover`` is set to ``True``, annotations are displayed when the mouse
hovers over the artist, without the need for clicking.


.. image:: /examples/images/sphx_glr_hover_001.png
    :class: sphx-glr-single-img





.. code-block:: default


    import matplotlib.pyplot as plt
    import numpy as np
    import mplcursors
    np.random.seed(42)

    fig, ax = plt.subplots()
    ax.scatter(*np.random.random((2, 26)))
    ax.set_title("Mouse over a point")

    mplcursors.cursor(hover=True)

    plt.show()


.. _sphx_glr_download_examples_hover.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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