matshow函数
来源:互联网 发布:时时彩源码下载 编辑:程序博客网 时间:2024/06/08 02:54
"""Simple matshow() example."""import matplotlib.pyplot as pltimport numpy as npdef 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 2 matrices of different sizesdimlist = [(12, 12), (15, 35)]for d in dimlist: plt.matshow(samplemat(d))# Display a random matrix with a specified figure number and a grayscale# colormapplt.matshow(np.random.rand(64, 64), fignum=100, cmap=plt.cm.gray)plt.show()
0 0