从发电机绘制matplotlib

时间:2015-01-22 20:43:55

标签: python matplotlib iterator generator

是否可以从生成器生成matplotlib图而无需预先指定图的总数?例如:

import numpy as np
import matplotlib.pyplot as plt

def gen():
    for i in range(10):
        yield np.random.random(100)

# Here something magic to avoid setting number of rows 
fig, ax = plt.subplots(undetermined, 1) 
g = gen()
for i, arr in enumerate(g):    
    ax[i].plot(arr)

我们的想法是生成不同的图,而不删除之前的图,直到StopIteration。有什么东西可以允许这种行为吗?

0 个答案:

没有答案