我想对此图进行动画处理,并尝试遍历第一列中的行以设置x0值,第二列中的行设置y0值。我该如何正确地将x0的值设置为y0以使其正确动画?
完整代码如下:
FFMpegWriter = manimation.writers['ffmpeg']
metadata = dict(title='Movie Test', artist='Matplotlib',
comment='Movie support!')
writer = FFMpegWriter(fps=15, metadata=metadata)
if __name__ == "__main__":
import glob
filenames = glob.glob(r"C:\Users\Admin\Desktop\hiddenforprivacy)
for fn in filenames[8:9]:
tups = bball.stats_basketball.read_tuples(fn)
positions = bball.stats_basketball.get_positions(tups)
goals = bball.stats_basketball.get_goals(tups)
fig = plt.figure()
with writer.saving(fig, "writer_test.mp4", 100):
for x in range(100):
for i in range(1, 6):
p_o = positions[i]
x0, y0 = p_o[0,0], p_o[0,1]
#where i started and am now stuck
#for row in p_o[:,0]:
if i == 1:
l, = plt.plot([],[], color='steelblue', linewidth=5)
l.set_data(x0,y0)
writer.grab_frame()