我有这样的数据:
我可以画出这样的图没问题:
图形是通过以下代码创建的:
import matplotlib.pyplot as plt
%matplotlib notebook
x = test['GameNumber']
y = test['Keely Pts']
y2 = test['Felicia Pts']
y3 = test['Alex Pts']
plt.plot(x, y, label='Keely')
plt.plot(x, y2, label='Felicia')
plt.plot(x, y3, label='Alex')
plt.xlabel('Game Number')
plt.ylabel('Game Value')
plt.title('Number of Correct Games')
plt.legend()
plt.show()
我的问题 每次绘制数据点时,我都要“暂停”或“等待”。每场比赛,三个玩家都被标绘,然后有一个0.5秒或整秒的停顿,然后再标绘下一场比赛的数据
如何将wait()计时器添加到matplotlib?我试着查看matplotlib上的文档,甚至动画模块,因为它非常关注sin
、cos
和pi
,我迷失在杂草中,找不到与我的问题类似的例子
我试着遵循这个example on stackOverflow,但是当我疲于实现它时,它只是闪现了我的图1,然后绘图变成了空白。这是我的密码:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
x = test['GameNumber']
y = test['Keely Pts']
fig, ax = plt.subplots()
line, = ax.plot(x, y, color='k')
def update(num, x, y, line):
line.set_data(x[:num], y[:num])
line.axes.axis([0, 10, 0, 1])
return line,
ani = animation.FuncAnimation(fig, update, len(x), fargs=[x, y, line],
interval=25, blit=False)
# ani.save('test.gif')
plt.show()
目前没有回答
相关问题 更多 >
编程相关推荐