I want to animate circles and lines with matplotlib. I was able to to this with circles, but not with lines. The following code works for the circles(without the line parts). With the line-parts, matplotlib just opens a white window.
#imports...
#create figure called ax
mypatch[0] = plt.Circle((0, 0), 0.75, fc='y')
mypatch[1] = plt.Circle((0, 0), 0.75, fc='y')
#... more patches
myline[0] = lin.Line2D([0,0],[0,0],color='b')
myline[1] = lin.Line2D([0,0],[0,0],color='b')
#... more lines
def init():
ax.add_patch(mypatch[0])
ax.add_patch(mypatch[1])
#...
ax.add_line(myline[0])
ax.add_line(myline[1])
#...
return mypatch, myline
def animate(i):
#trajectory of mypatch and myline
return mypatch, myline
anim = anmiation.FuncAnimation(fig, animate, init_func=init,...)
plt.show()