虽然@Zhenya的答案可以解决问题,但我更倾向于使用matshow
而不是imshow
import pylab as plt
a = [[1,0,1],[1,1,1]]
plt.matshow(a)
plt.show()
您无需调用插值(interpolation)
参数,默认情况下轴为整数。例如:
>>> a = [[1,0,1],[1,1,1]]
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> fig, ax = plt.subplots()
>>> ax.imshow(a, interpolation='nearest')
<matplotlib.image.AxesImage object at 0x354ecd0>
>>> plt.draw()
imshow
函数。 - Bonlenfum