
.. 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

    .. meta::
        :keywords: codex

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

        :ref:`Go to the end <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:


===============================
Visualize matrices with matshow
===============================

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

.. GENERATED FROM PYTHON SOURCE LINES 8-18

.. code-block:: Python

    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_00x.png 2.00x
   :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 sphx-glr-footer-example

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

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

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

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

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

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


.. only:: html

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

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