I am trying to create an animation of growing concentric circles in python. As the program runs, more circles should generate from the centre and grow outwards
Right now I have this, which just creates one expanding circle.
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
fig = plt.figure()
ax = plt.axes(xlim=(0, 128), ylim=(0, 128))
line, = ax.plot([], [], lw=2)
def init():
line.set_data([], [])
return line,
def animate(i):
theta = np.linspace(0, 2 * np.pi, 100)
r = np.sqrt(i)
x = r * np.cos(theta) + 64
y = r * np.sin(theta) + 64
line.set_data(x, y)
return line,
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=1000, interval=10, blit=True)
plt.gca().set_aspect('equal', adjustable='box')
plt.show()
How do I modify my code so that new growing circles generate from the middle to create growing concentric circles.