我在玩一些大数据集,这些数据集随着我可以控制的某个参数的函数而变化。 现在我想在同一个图的子图中绘制数据的分布。然而,由于构造直方图需要很大的数据。在
所以,我希望子图,因为他们完成了一点像下面。在
import matplotlib.pyplot as plt
import numpy as np
import numpy.random as npr
Ne=10
MC=1000000
f1d,f2d = plt.figure(),plt.figure()
for Part in range(Ne):
datax=npr.normal(size=MC)+4*Part/Ne ##Simulates my big data
datay=npr.normal(size=MC) ##Simulates my big data
###The 1d histogram
sf1d = f1d.add_subplot(1,Ne,Part+1,)
sf1d.hist(datax,bins=20,normed=True,histtype='stepfilled',alpha=0.5)
sf1d.hist(datay,bins=20,normed=True,histtype='stepfilled',alpha=0.5)
plt.show(block=False)
###Some flush argument()
###The 2d histogram
sf2d = f2d.add_subplot(1,Ne,Part+1)
sf2d.hist2d(datax,datay,bins=20,normed=True)
plt.show(block=False)
###Some flush argument()
但是,python不会实时绘制所有的子图,而是缓冲这些子图,直到循环完成。 如何强制matplotlib立即刷新子图?在
从^{} docs :
相关问题 更多 >
编程相关推荐