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

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

.. _sphx_glr_gallery_widgets_cursor.py:


======
Cursor
======





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





.. code-block:: python

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


    # Fixing random state for reproducibility
    np.random.seed(19680801)

    fig = plt.figure(figsize=(8, 6))
    ax = fig.add_subplot(111, facecolor='#FFFFCC')

    x, y = 4*(np.random.rand(2, 100) - .5)
    ax.plot(x, y, 'o')
    ax.set_xlim(-2, 2)
    ax.set_ylim(-2, 2)

    # Set useblit=True on most backends for enhanced performance.
    cursor = Cursor(ax, useblit=True, color='red', linewidth=2)

    plt.show()


.. _sphx_glr_download_gallery_widgets_cursor.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: cursor.ipynb <cursor.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>`_
