
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/image.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_examples_image.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_image.py:


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

... display the underlying data value.

.. GENERATED FROM PYTHON SOURCE LINES 7-27



.. image-sg:: /examples/images/sphx_glr_image_001.png
   :alt: Click anywhere on the image
   :srcset: /examples/images/sphx_glr_image_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    from matplotlib.offsetbox import AnnotationBbox, OffsetImage
    import matplotlib.pyplot as plt
    import numpy as np
    import mplcursors

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

    fig, axs = plt.subplots(ncols=2)
    axs[0].imshow(data, origin="lower")
    axs[1].imshow(data, origin="upper", extent=[2, 3, 4, 5])

    axs[1].set(xlim=(2, 4), ylim=(4, 6))
    axs[1].add_artist(AnnotationBbox(OffsetImage(data), (3.5, 5.5)))

    mplcursors.cursor()

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

    plt.show()


.. _sphx_glr_download_examples_image.py:

.. only:: html

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

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

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

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

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: image.zip <image.zip>`


.. only:: html

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

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