I want to animate the scatter plot based on the actual timestamp from the csv file (see below). I'm not so good with matplotlib and I know of the animation function and the ion()-function but I'm not sure how to implement it. I read this but it seemed very difficult to implement it in my way. I have tried the code below but it only shows me every loop a new window with the actual data but I would like to have the animation in one window thanks in advance :):
import pandas as pd
import matplotlib.pyplot as plt
start_time = 86930.00
end_time = 86934.00
df = pd.read_csv('Data.csv', delimiter=',')
for timestamp in range(int(start_time), int(end_time), 1):
act_data = df.loc[df['timestamp'] == float(timestamp)]
X = act_data.x
Y = act_data.y
plt.scatter(X, Y)
plt.show()
Data.csv:
timestamp,id,x,y
86930.00,1,1155.53,7155.05
86930.00,2,3495.08,8473.46
86931.00,1,3351.04,6402.27
86931.00,3,3510.59,8021.62
86931.00,2,2231.04,6221.27
86931.00,4,3710.59,8111.62
86932.00,2,3333.01,6221.27
86932.00,1,3532.59,3178.62
86933.00,3,1443.01,2323.27
86933.00,4,5332.59,1178.62
It would be cool if I could color the blobs by ID but not necessary :).