Mic*_*ter 9 macos graphing focus matplotlib python-2.7
我的代码正在从 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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1732 次 |
| 最近记录: |