I would like to animate my 3D figure, but somehow it doesnt work. The figure contains positional data in 3 axis (x,y,z) of 4 markers on a rigid body. I would like to animate how the positional data of all markers changes over time. Can somebody help me?
This is the script:
#animation function
def animate_func(num, data, line):
ax.plot3D(x1[num:, 0], y1[num:, 0], z1[num:, 0], c='blue')
ax.plot3D(x1[num:], y1[num:], z1[num:], c='blue', marker='o')
ax.plot3D(x1[0, 0], y1[1, 0], z1[2, 0], c='black', marker='o')
#lines = ax.plot(x, y, z, lw=2, c='g')
path_scatter = ax.scatter(x1, y1, z1, lw=2, c= '#fe7d11', s=1)
start = ax.plot(x1[0], y1[0], z1[0], c='black', marker='o')
numDataPoints=len(t)
anim = animation.FuncAnimation(figure11, animate_func, frames=numDataPoints, interval=100, blit=False)
#lines = ax.plot(x, y, z, lw=2, c='g')
path_scatter = ax.scatter(x2, y2, z2, lw=2, c='#0d5ebc', s=1)
start = ax.plot(x2[0], y2[0], z2[0], c='black', marker='o')
numDataPoints=len(t)
anim = animation.FuncAnimation(figure11, animate_func, frames=numDataPoints, interval=100, blit=False)
#lines = ax.plot(x, y, z, lw=2, c='g')
path_scatter = ax.scatter(x3, y3, z3, lw=2, c='#409d2b', s=1)
start = ax.plot(x3[0], y3[0], z3[0], c='black', marker='o')
numDataPoints=len(t)
anim = animation.FuncAnimation(figure11, animate_func, frames=numDataPoints, interval=100, blit=False)
#lines = ax.plot(x, y, z, lw=2, c='g')
path_scatter = ax.scatter(x4, y4, z4, lw=2, c='#ce2602', s=1)
start = ax.plot(x4[0], y4[0], z4[0], c='black', marker='o')
numDataPoints=len(t)
anim = animation.FuncAnimation(figure11, animate_func, frames=numDataPoints, interval=100, blit=False)
writervideo = animation.FFMpegWriter(fps=60)
anim.save('animation.mp4', writer=writervideo)
plt.show()
#plt.close()
Thanks in advance!