如何解决创建实时条形图
我无法使用实时条形图。 来自 twitter 的传入数据如下所示(文件内的数据):
Snake: 5
Code: 3
Python: 7
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("wordsToGraph.txt","r").read()
dataArray = pullData.split('\n')
xar = []
yar = [] for eachLine in dataArray:
if len(eachLine)>1:
x,y = eachLine.split(':')
xar.append(str(x))
yar.append(int(y))
ax1.clear()
ax1.bar(xar,yar)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
TypeError: animate() missing 1 required positional argument: 'i'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。