

.. _sphx_glr_examples_basic.py:


mplcursors' core functionality
==============================

... is to add interactive data cursors to a figure.




.. image:: /examples/images/sphx_glr_basic_001.png
    :align: center





.. 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()
    lines = ax.plot(data)
    ax.set_title("Click somewhere on a line.\nRight-click to deselect.\n"
                 "Annotations can be dragged.")
    fig.tight_layout()

    mplcursors.cursor(lines)

    plt.show()



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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