:orphan:



.. _sphx_glr_examples:

.. _examples:

:mod:`mplcursors` examples
==========================

As `mplcursors` is fundamentally a library for interactivity, you should
download the examples and try them yourself :-)

.. vim: ft=rst



.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="... is to add interactive data cursors to a figure.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_basic_thumb.png
     :alt: mplcursors' core functionality

     :ref:`sphx_glr_examples_basic.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/basic

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="When *hover* is set to True, annotations are displayed when the mouse hovers over the artist, w...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_hover_thumb.png
     :alt: Annotate on hover

     :ref:`sphx_glr_examples_hover.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/hover

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Use an event handler to customize the popup.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_change_popup_color_thumb.png
     :alt: Changing properties of the popup

     :ref:`sphx_glr_examples_change_popup_color.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/change_popup_color

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Contour plot support is limited to picking the individual LineCollection\s, which are directly ...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_contour_thumb.png
     :alt: Contour plots

     :ref:`sphx_glr_examples_contour.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/contour

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="... display the underlying data value.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_image_thumb.png
     :alt: Cursors on images

     :ref:`sphx_glr_examples_image.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/image

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="mplcursors correctly formats datetime data.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_date_thumb.png
     :alt: Datetime data

     :ref:`sphx_glr_examples_date.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/date

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Using an event handler to change the annotation text and position.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_bar_thumb.png
     :alt: Display a bar's height and name on top of it upon hovering

     :ref:`sphx_glr_examples_bar.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/bar

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Use an event handler to change the annotation text.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_artist_labels_thumb.png
     :alt: Display an artist's label instead of x, y coordinates

     :ref:`sphx_glr_examples_artist_labels.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/artist_labels

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="mpldatacursor&#x27;s *point_labels* functionality can be emulated with an event handler that sets th...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_labeled_points_thumb.png
     :alt: Displaying a custom label for each individual point

     :ref:`sphx_glr_examples_labeled_points.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/labeled_points

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="DataFrame\s can be used similarly to any other kind of input. Here, we generate a scatter plot ...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_dataframe_thumb.png
     :alt: Extracting data and labels from a :class:`~pandas.DataFrame`

     :ref:`sphx_glr_examples_dataframe.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/dataframe

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Just pass highlight=True to cursor.">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_highlight_thumb.png
     :alt: Highlighting the artist upon selection

     :ref:`sphx_glr_examples_highlight.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/highlight

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, mplcursors uses &quot;t&quot; to toggle interactivity and &quot;d&quot; to hide/show annotation boxes. ...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_keyboard_shortcuts_thumb.png
     :alt: Keyboard shortcuts

     :ref:`sphx_glr_examples_keyboard_shortcuts.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/keyboard_shortcuts

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An example of connecting to cursor events: when an artist is selected, also highlight its &quot;part...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_paired_highlight_thumb.png
     :alt: Linked artists

     :ref:`sphx_glr_examples_paired_highlight.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/paired_highlight

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="... as opposed to lines with a &quot;.&quot; style, which have the same appearance, but are highlighted a...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_scatter_thumb.png
     :alt: Scatter plots are highlighted point-by-point.

     :ref:`sphx_glr_examples_scatter.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/scatter

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A selection on a step plot holds precise information on the x and y position in the sel.index a...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_step_thumb.png
     :alt: Step plots

     :ref:`sphx_glr_examples_step.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/step

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, each Cursor will ever display one annotation at a time.  Pass multiple=True to disp...">

.. only:: html

 .. figure:: /examples/images/thumb/sphx_glr_nondraggable_thumb.png
     :alt: Using multiple annotations and disabling draggability via signals

     :ref:`sphx_glr_examples_nondraggable.py`

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /examples/nondraggable
.. raw:: html

    <div class="sphx-glr-clear"></div>



.. only :: html

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


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

    :download:`Download all examples in Python source code: examples_python.zip </examples/examples_python.zip>`



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

    :download:`Download all examples in Jupyter notebooks: examples_jupyter.zip </examples/examples_jupyter.zip>`


.. only:: html

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

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