python matplotlib显示单色图问题

 def initArray(num):
    img = np.zeros((256,256))
    for x in range(0,256):
        for y in range(0,256):
            img[x][y] = num
    return img 
fig = plt.figure()  

ax = fig.add_subplot() 

ax.imshow(initArray(20),cmap='gray')  
plt.show()

按说initArray的参数变化,显示的图片应该是不同的单色图,可是显示显示的全是黑色怎么回事?

还有就是如果我修改了data里的一个数值,整个的图片颜色就全变成白色了怎么回事。