You are reading an old version of the documentation (v2.1.2). For the latest version see https://matplotlib.org/stable/gallery/images_contours_and_fields/matshow.html
Version 2.1.2
matplotlib
Fork me on GitHub


Travis-CI:

Related Topics

This Page

MatshowΒΆ

Simple matshow() example.

../../_images/sphx_glr_matshow_001.png
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.018 seconds)

Gallery generated by Sphinx-Gallery