我的代码从Arduino接收串行数据,对其进行处理,然后绘制图表。我使用matplotlib作为图形界面。每次它“绘制”时,它会强制吸引注意力,用户将无法查看除此之外的任何内容。如何最好地使其停止?(代码除了窃取焦点外都可以正常运行)。我尝试使用matplotlib.use('Agg')方法,因为在另一篇帖子上看到过,但它没有起作用。(使用MAC OS X)。
下面展示的代码是更新数据的超级简单图形,我遇到了同样的问题。我不展示我的代码,因为没有正确的输入无法复制粘贴。
下面展示的代码是更新数据的超级简单图形,我遇到了同样的问题。我不展示我的代码,因为没有正确的输入无法复制粘贴。
import matplotlib
from matplotlib import *
from pylab import *
# import math
x=[]
y=[]
def function(iteration):
xValue=iteration#Assigns current x value
yValue=(1./iteration)*34#Assigns current y value
x.extend([xValue]) #adds the current x value to the x list
y.extend([yValue]) #adds the current y value to the y list
clf() #clears the plot
plot(x,y,color='green') #tells the plot what to do
draw() #forces a draw
def main():
for i in range(1,25): #run my function 25 times (24 I think actually)
function(i)
pause(.1)
main()