matplotlib将矩阵显示成图片matshow

介绍

该函数用于绘制矩阵

功能与 matplotlib.pyplot.matshow类似

语法

matshow(A, fignum=None, **kwargs)

例子

用matshow()显示矩阵

import numpy as np
import matplotlib.pyplot as plt

arr = np.arange(10000).reshape(100,100)
plt.matshow(arr)

用imshow()显示矩阵

用imshow()函数显示相同的矩阵

import numpy as np
import matplotlib.pyplot as plt

arr = np.arange(10000).reshape(100,100)
plt.imshow(arr)

功能类似,但坐标不同,如下图:


原文出处:/show_1EF5D9XqnDsr.html