I'm trying to simulate from scratch the motion of a planet in a binary star system. For this I need to be able to plot points in an animated graph. Before coding the whole thing, I'm learning to animate a plot using pyplot. So far I haven't had any luck animating a moving point. After looking at several tutorials and at the documentation this what I've got:
import matplotlib
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.set_xlim(0,2)
ax.set_ylim(0,2)
line, = plt.plot(0,0,'bo')
def animation(i):
x=np.linspace(0,2,100)
y=np.linspace(0,1,100)
line.set_data(x[i],y[i],'bo')
return line,
FuncAnimation(fig, animation, frames=np.arange(100),interval=10)
plt.show()
However the output of this code is just a point at 0,0 and I don't understand what I may be doing wrong.