Вы можете сохранить список строк и добавлять новую каждые несколько кадров с меньшим радиусом
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))
# Keep a list of lines instead of a single one
lines = ax.plot([], [], lw=2)
def init():
for line in lines:
line.set_data([], [])
return lines
def animate(i):
# Add a new line every 100 frames
if i // 100 >= len(lines):
new_line, = ax.plot([], [], lw=2)
lines.append(new_line)
for line_num, line in enumerate(lines):
theta = np.linspace(0, 2 * np.pi, 100)
# Reduce the radius of the new lines
r = np.sqrt(i - 100 * line_num)
x = r * np.cos(theta) + 64
y = r * np.sin(theta) + 64
line.set_data(x, y)
return lines
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=1000, interval=10, blit=True)
plt.gca().set_aspect('equal', adjustable='box')
plt.show()