Skip to content

Instantly share code, notes, and snippets.

@parulnith
parulnith / Moving Sine Wave.py
Last active August 17, 2022 07:36
Using matplotlib's FuncAnimation to do a basic animation of a sine wave moving across the screen:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
plt.style.use('seaborn-pastel')
fig = plt.figure()
ax = plt.axes(xlim=(0, 4), ylim=(-2, 2))
line, = ax.plot([], [], lw=3)