.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` 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. .. 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:: /gallery/images_contours_and_fields/images/sphx_glr_matshow_001.png :alt: matshow :class: sphx-glr-single-img ------------ References """""""""" The use of the following functions and methods is shown in this example: .. code-block:: default import matplotlib matplotlib.axes.Axes.matshow matplotlib.pyplot.matshow .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. _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 ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: matshow.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_