0
以下のコードは、私が書いたコードのスニペットです。基本的にはtkinterウィンドウにグラフが表示されますが、アニメーションの追加には苦労します。グラフを更新(更新)します。以下は、私が得ているエラーです、どんな助けも大いに感謝されるでしょう。matplotlib.animation - AttributeError: 'NoneType'オブジェクトに 'new_timer'属性がありません
Traceback (most recent call last):
File "C:\Users\nasto\Documents\Company\CMSFRAME.py", line 163, in <module>
ani = animation.FuncAnimation (f, animate, interval=1000)
File "C:\Users\nasto\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\animation.py", line 1462, in __init__
TimedAnimation.__init__(self, fig, **kwargs)
File "C:\Users\nasto\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\animation.py", line 1225, in __init__
event_source = fig.canvas.new_timer()
AttributeError: 'NoneType' object has no attribute 'new_timer'
私のコードの抜粋:
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand = True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand = True)
f = Figure(figsize = (5,5), dpi=100)
a = f.add_subplot(111)
def animate(interval):
pullData = open('financeData.txt','r').read()
dataList = pullData.split('\n')
xList = []
yList=[]
for eachLine in dataList:
if len(eachline) >1:
x, y = eachLine.split(',')
xList.append(int(x))
yList.append(int(x))
a.clear()
a.plot(xList, yList)
app = start()
ani = animation.FuncAnimation (f, animate, interval=1000)
animate関数は何も返しません。例を確認してくださいhttp://matplotlib.org/2.0.0/examples/animation/animate_decay.html – maz
まだエラーが表示されます –
何を変更しましたか?あなたのアニメーション関数は、 ''行、= ax.plot([]、[]、lw = 2) ''のような行オブジェクトを返さなければなりません。あなたは何も返しません。 – maz