Skip to content

Instantly share code, notes, and snippets.

@ShuaiGuo16
Last active December 28, 2020 12:05
Show Gist options
  • Save ShuaiGuo16/2385a7bdaa549dd149e261b8068ca139 to your computer and use it in GitHub Desktop.
Save ShuaiGuo16/2385a7bdaa549dd149e261b8068ca139 to your computer and use it in GitHub Desktop.
Animate multiple trajectories
# Create individual frames
for i in range(0,30):
for j in range(1,traj_X.shape[1]+1):
# Projectile's trajectory
x = traj_X[i][0:j]
y = traj_Y[i][0:j]
# Show Projectile's location
ax.plot(x[-1], y[-1], marker='o', markersize=12,
markeredgecolor='r', markerfacecolor='r')
# Show Projectile's trajectory
ax.plot(x, y, color='b', lw=2, linestyle='--')
# Capture frame
camera.snap()
# Create animation
anim = camera.animate(interval = 40, repeat = True, repeat_delay = 500)
HTML(anim.to_html5_video())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment