

.. _sphx_glr_gallery_pylab_examples_matshow.py:


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

Simple matshow() example.




.. image:: /gallery/pylab_examples/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()

**Total running time of the script:** ( 0 minutes  0.022 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
