Skip to content

Instantly share code, notes, and snippets.

@RadoslawB
Created June 9, 2018 18:09
Show Gist options
  • Save RadoslawB/8457367c78f1507eed95eb9b0ac7ce4d to your computer and use it in GitHub Desktop.
Save RadoslawB/8457367c78f1507eed95eb9b0ac7ce4d to your computer and use it in GitHub Desktop.
from matplotlib import animation
predictions_history = []
# append arrays of Y_test values to predictions hostory
fig, ax = plt.subplots()
ax.grid()
scatter = ax.scatter(X_train,Y_train, s=5, c='r')
parabola, = ax.plot(X_train, predictions_history[0])
# initialization function: plot the background of each frame
def init():
return parabola,
# animation function. This is called sequentially
def animate(i):
parabola.set_ydata(predictions_history[i])
return parabola,
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=50, interval=10, blit=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment