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

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

.. _sphx_glr_gallery_widgets_multicursor.py:


===========
Multicursor
===========

Showing a cursor on multiple plots simultaneously.

This example generates two subplots and on hovering the cursor over data in one
subplot, the values of that datapoint are shown in both respectively.




.. image:: /gallery/widgets/images/sphx_glr_multicursor_001.png
    :class: sphx-glr-single-img





.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.widgets import MultiCursor

    t = np.arange(0.0, 2.0, 0.01)
    s1 = np.sin(2*np.pi*t)
    s2 = np.sin(4*np.pi*t)

    fig, (ax1, ax2) = plt.subplots(2, sharex=True)
    ax1.plot(t, s1)
    ax2.plot(t, s2)

    multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)
    plt.show()


.. _sphx_glr_download_gallery_widgets_multicursor.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
