Created
January 23, 2021 06:12
-
-
Save Park-Developer/7d59132c652e857b4fc4868030bf13ef to your computer and use it in GitHub Desktop.
matplotlib : animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.animation import FuncAnimation | |
fig, ax = plt.subplots() | |
xdata, ydata = [], [] | |
ln, = plt.plot([], [], 'ro') | |
def init(): | |
ax.set_xlim(0, 2*np.pi) | |
ax.set_ylim(-1, 1) | |
return ln, | |
def update(frame): | |
xdata.append(frame) | |
ydata.append(np.sin(frame)) | |
ln.set_data(xdata, ydata) | |
return ln, | |
ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128), | |
init_func=init, blit=True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment