我有一个6x6矩阵代表一个网格。以下网格(3)的较小部分表示为3xi:
In [65]:
arr = np.zeros((6,6))
arr[0:3, 0:3] = 1
arr
Out[65]:
array([[ 1., 1., 1., 0., 0., 0.],
[ 1., 1., 1., 0., 0., 0.],
[ 1., 1., 1., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.]])
我希望绘制这个图,但是matplotlib没有对齐,如下所示。红方应该在水平轴和垂直轴上覆盖0到3的区域。在
^{pr2}$我怎么解决这个问题?谢谢你
可以对标签使用主刻度,对网格使用次要刻度。在
考虑:
这表明:
诀窍就在这两行:
^{pr2}$如果您愿意,您可以使用:
然而,标准行为与预期一致:以(0,0)为中心的像素具有元素(0,0)的值。在
相关问题 更多 >
编程相关推荐