I am struggling to animate a 3d graph using python. I want the code to draw the graph frame by frame, so that I know the movement of the subject by time. (I'm using motion analysis data and I'm trying to graph the movement of a subject.) All my data is stored in a csv file, which I configured to a 3*200 array. (3 columns for x, y, z axis; data4
) Here is my code:
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.animation as animation
df = pd.DataFrame(data4, columns = ["x", "y", "z"])
fig = plt.figure()
ax = fig.add_subplot(111, projection = "3d")
def update(i):
offsets3d = (df.x.values[:i], df.y.values[:i], df.y.values[:i])
ax.set_xlim(-500,500)
ax.set_ylim(-500,500)
ax.set_zlim(-500,500)
ani = animation.FuncAnimation(fig, update, frames =len(df), interval = 250)
plt.show()