.. 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 ======= Simple `~.axes.Axes.matshow` example. .. code-block:: python import matplotlib.pyplot as plt import numpy as np def samplemat(dims): """Make a matrix with all zeros and increasing elements on the diagonal""" aa = np.zeros(dims) for i in range(min(dims)): aa[i, i] = i return aa # Display matrix plt.matshow(samplemat((15, 15))) plt.show() .. image:: /gallery/images_contours_and_fields/images/sphx_glr_matshow_001.png :class: sphx-glr-single-img ------------ References """""""""" The use of the following functions and methods is shown in this example: .. code-block:: python import matplotlib matplotlib.axes.Axes.matshow matplotlib.pyplot.matshow .. _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 :download:`Download Python source code: matshow.py ` .. container:: sphx-glr-download :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 `_