Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/JSAnimation/template/make_frames.py
934 views
1
"""
2
Create some sample animation frames for testing
3
"""
4
import numpy as np
5
import matplotlib.pyplot as plt
6
7
x = np.linspace(0, 10, 1000)
8
9
fig, ax = plt.subplots(figsize=(4, 3))
10
line, = plt.plot(x, np.sin(x), '-b', lw=2)
11
ax.set_xlim(0, 10)
12
ax.set_ylim(-2, 2)
13
14
for i in range(100):
15
line.set_data(x, np.cos(i * 0.02 * np.pi) * np.sin(x - i * 0.02 * np.pi))
16
fig.savefig('frames/frame%.03i.png' % (i + 1))
17
18