.. _sphx_glr_gallery_images_contours_and_fields_matshow.py: ======= Matshow ======= Simple matshow() example. .. image:: /gallery/images_contours_and_fields/images/sphx_glr_matshow_001.png :align: center .. 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, 35))) plt.show() .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: https://static.mybinder.org/badge.svg :target: https://mybinder.org/v2/gh/choldgraf/matplotlib/gh-pages?filepath=_downloads/matshow.ipynb :width: 150 px .. 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 `Gallery generated by Sphinx-Gallery `_