

.. _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
    :align: center





.. code-block:: python


    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()



.. only :: html

 .. container:: sphx-glr-footer


  .. 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>`_
