Version 3.1.2
matplotlib

Table of Contents

Related Topics

Matshow

Simple matshow example.

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

Simple `~.axes.Axes.matshow` example.
"""
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()
Traceback (most recent call last):
  File "/build/matplotlib-tq5J6U/matplotlib-3.1.2/examples/images_contours_and_fields/matshow.py", line 1
    =======
    ^
SyntaxError: invalid syntax

References

The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.matshow
matplotlib.pyplot.matshow

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery