diff options
Diffstat (limited to 'vis/animation/line_plot_ani.py')
| -rw-r--r-- | vis/animation/line_plot_ani.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vis/animation/line_plot_ani.py b/vis/animation/line_plot_ani.py new file mode 100644 index 0000000..21ed9cd --- /dev/null +++ b/vis/animation/line_plot_ani.py @@ -0,0 +1,35 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation + +fig, ax = plt.subplots() +xdata, ydata = [], [] +ln, = ax.plot([], [], 'ro') + +ax.set_xlim(0, 2*np.pi) +ax.set_ylim(-1, 1) + + +def init(): + # print('init') + ax.set_xlim(0, 2*np.pi) + ax.set_ylim(-1, 1) + return ln, + + +def animate(i): + # print('animate', i) + xdata.append(i) + ydata.append(np.sin(i)) + ln.set_data(xdata, ydata) + return ln, + + +ani = FuncAnimation(fig, + animate, + frames=np.linspace(0, 2*np.pi, 128), + # init_func=init, + blit=True + ) +plt.show() + |
