I have a df
consisting of two different frames for each observation, denoted by the ending character in the variable
name x1 y1 x2 y2
0 bob 3 2 1 4
1 amy 2 1 4 3
2 pam 6 3 3 1
3 joe 4 2 6 5
I am wondering how to create an animation consisting of two frames ([x1,y1],[x2,y2]). I have seen resources on how to create animations with line and bar charts, but I couldn't find much info on scatterplot animations.
The response to this question seems a bit complicated for my application.
Things I have tried:
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure(figsize=(5,5))
scatter=ax.scatter(df["x1"], df["y1"])
def animate():
scatter.set_data(df[['x2','y2'])
Is my dataframe set up correctly for this? I would also like to annotate these points, but I know how to do that with the adjustText
package, so that isn't a problem here, right? I'm assuming I don't have to set the annotations like I have to set the data.
Any help is appreciated. Thanks!