Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2021 19:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jairajsahgal/168e2ebf3a9d2ff91abc033dbd803687 to your computer and use it in GitHub Desktop.
Animation of sin wave in python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# References
def func(t, line):
t = np.arange(0, t, 0.1)
y = np.sin(t)
line.set_data(t, y)
return line
fig = plt.figure()
ax = plt.axes(xlim=(0, 100), ylim=(-1.2, 1.22))
redDots = plt.plot([], [], 'ro')
line = plt.plot([], [], lw=2)
# Creating the Animation object
line_ani = animation.FuncAnimation(fig, func, frames=np.arange(1, 100, 0.1), fargs=(line), interval=10, blit=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment