Matshow

简单的 matshow 例子。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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()

matshow示例

参考

此示例中显示了以下函数和方法的用法:

1
2
3
import matplotlib
matplotlib.axes.Axes.matshow
matplotlib.pyplot.matshow

下载这个示例