Matplotlib FuncAnimation для точечного графика
Я пытаюсь использоватьFuncAnimation
Matplotlib для анимации отображения одной точки на кадр анимации.
# modules
#------------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as py
from matplotlib import animation
py.close('all') # close all previous plots
# create a random line to plot
#------------------------------------------------------------------------------
x = np.random.rand(40)
y = np.random.rand(40)
py.figure(1)
py.scatter(x, y, s=60)
py.axis([0, 1, 0, 1])
py.show()
# animation of a scatter plot using x, y from above
#------------------------------------------------------------------------------
fig = py.figure(2)
ax = py.axes(xlim=(0, 1), ylim=(0, 1))
scat = ax.scatter([], [], s=60)
def init():
scat.set_offsets([])
return scat,
def animate(i):
scat.set_offsets([x[:i], y[:i]])
return scat,
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=len(x)+1,
interval=200, blit=False, repeat=False)
К сожалению, финальный анимационный сюжет отличается от оригинального сюжета. Анимированный сюжет также мигает несколькими точками во время каждого кадра анимации. Любые предложения о том, как правильно анимировать точечный график, используяanimation
пакет?