【发布时间】:2018-11-25 15:00:38
【问题描述】:
我有一个由随机整数数组构建的方阵,定义如下:
import numpy as np
dim_low, dim_high = 0, 20 #array of random integers' dimensions
matrix = np.random.random_integers(low = dim_low,high = dim_high, size=(dim_high,dim_high))
print(matrix) #the matrix of defined with repetitions of the array.
图中得到的矩阵: https://i.stack.imgur.com/eEcCh.png
如何使用 Matplotlib 绘制在网格中生成的矩阵,以将每个单元格的值(权重)打印在每个单元格的中心,并且在 x 中有一个从 0 到 20 的比例一个 y 轴,如下图 图片 (注意 'x' 和 'o' 是示例中的文本,我需要的是权重,整数形式,而不是文本形式):
【问题讨论】:
-
如果您能够生成显示的图像,那么将矩阵元素放在文本中而不是一些字母
"o"有什么区别?您要解决的具体问题是什么?
标签: python matplotlib matrix grid