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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_images_contours_and_fields_matshow.py>`
        to download the full example code

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

.. _sphx_glr_gallery_images_contours_and_fields_matshow.py:


=======
Matshow
=======

`~.axes.Axes.matshow` visualizes a 2D matrix or array as color-coded image.

.. GENERATED FROM PYTHON SOURCE LINES 8-18

.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np

    # a 2D array with linearly increasing values on the diagonal
    a = np.diag(range(15))

    plt.matshow(a)

    plt.show()




.. image-sg:: /gallery/images_contours_and_fields/images/sphx_glr_matshow_001.png
   :alt: matshow
   :srcset: /gallery/images_contours_and_fields/images/sphx_glr_matshow_001.png, /gallery/images_contours_and_fields/images/sphx_glr_matshow_001_2_0x.png 2.0x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 19-25

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.axes.Axes.imshow` / `matplotlib.pyplot.imshow`


.. _sphx_glr_download_gallery_images_contours_and_fields_matshow.py:


.. only :: html

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



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

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



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

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