Skip to content

Instantly share code, notes, and snippets.

@grey-area
Created July 12, 2022 09:56
Show Gist options
  • Save grey-area/77823d127d05297ba0e039369c6027d1 to your computer and use it in GitHub Desktop.
Save grey-area/77823d127d05297ba0e039369c6027d1 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
from tqdm import tqdm
if __name__ == "__main__":
output_dir = Path('frames')
output_dir.mkdir(exist_ok=True)
xs = np.linspace(0, 4 * np.pi, 200)
fig, ax = plt.subplots(1, figsize=(12.8, 7.2))
num_frames = 300
for frame in tqdm(range(num_frames)):
ys = np.cos(xs + 0.01 * frame)
ax.plot(xs, ys)
plt.savefig(output_dir / f'{frame:03d}.png', dpi=100)
ax.clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment