【发布时间】:2014-02-05 14:13:04
【问题描述】:
我是 wx python 的新手。以下是从可以实时更新的文本文件中绘制实时图表的代码。谁能帮我将此代码嵌入到 wx 框架中。我的项目迫切需要它。
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
fig= plt.figure()
ax1=fig.add_subplot(1,1,1)
def animate(i):
pullData= open('C:/test/e.txt','r').read()
dataArray= pullData.split('\n')
xar=[]
yar=[]
for eachLine in dataArray:
if len(eachLine)>1:
x,y= eachLine.split(',')
xar.append(int(x))
yar.append(int(y))
ax1.clear()
ax1.plot(xar,yar)
ani= animation.FuncAnimation(fig,animate, interval=1000)
plt.show()
【问题讨论】:
-
有一些很好的例子here。
标签: python matplotlib wxwidgets