Python 设置pyplot子地块的动画

Python 设置pyplot子地块的动画,python,animation,matplotlib,plot,Python,Animation,Matplotlib,Plot,我已经广泛阅读了关于这个主题的文章,并花了几个小时寻找为我的情节实现动画的方法 我已经使用plt.ion()在循环中管理了一个“动画”,但是,我无法在matplotlib.animation中获得任何东西来生成动画剪辑 下面是我必须设置动画的数据的基本设置 import matplotlib.pyplot as plt import numpy as np class plot_output(object): def __init__(self): self.fig,

我已经广泛阅读了关于这个主题的文章,并花了几个小时寻找为我的情节实现动画的方法

我已经使用
plt.ion()
在循环中管理了一个“动画”,但是,我无法在
matplotlib.animation
中获得任何东西来生成动画剪辑

下面是我必须设置动画的数据的基本设置

import matplotlib.pyplot as plt
import numpy as np

class plot_output(object):
    def __init__(self):
        self.fig, self.ax = plt.subplots(2,10)
        plt.ion()
        plt.show()
    def iterate_animation(self, i, weight_list):
        X = weight_list[i]
        for i in range(20):
            self.ax[i/10, i%10].cla()
            wi = X[:,i]
            wi=wi.reshape((28,28))
            self.ax[i/10, i%10].axis('off')
            self.ax[i/10, i%10].imshow(wi,cmap=plt.cm.gist_yarg,
                interpolation='gaussian', aspect='equal')
        plt.draw()

w_list = [np.random.rand(784,20) for i in range(4)]
p = plot_output()

for i in range(4):
    p.iterate_animation(i=i, weight_list=w_list)