

.. _sphx_glr_examples_image.py:


Cursors on images
=================

... display the underlying data value.




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





.. code-block:: python


    import matplotlib.pyplot as plt
    import numpy as np
    import mplcursors

    data = np.arange(100).reshape((10, 10))

    fig, axes = plt.subplots(ncols=2)
    axes[0].imshow(data, interpolation="nearest", origin="lower")
    axes[1].imshow(data, interpolation="nearest", origin="upper",
                         extent=[200, 300, 400, 500])
    mplcursors.cursor()

    fig.suptitle("Click anywhere on the image")

    plt.show()



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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