为什么表现得这么慢

时间:2016-07-13 13:30:38

标签: python matplotlib

我试图简单地将68x68数组显示为具有高帧速率的图像。我尝试了很多,但我不知道set_data()是如何工作的?这段代码只产生1帧/秒,这不可能,或者?

你可以在代码中看到我尝试过,但它只显示一个黑色窗口,而不是开/关切换点?

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation

switch = 0

plt.ion()  #to update the matplot image ???
plt.gray()

image = np.zeros([68,68])
image_data = plt.imshow(image, animated=True)


plt.show(block=False)


while True:
        if switch == 0:
                switch = 1
                image[0][0] = 1
                image[0][10] = 0
        else:
                switch = 0
                image[0][0] = 0
                image[0][10] = 1

        plt.imshow(image)
        #plt.draw()
        #image_data.set_data(image)
        plt.draw()
##      plt.show()
        print "other work starts here"

关于为什么会发生这种情况的任何想法?

0 个答案:

没有答案