Skip to content

Instantly share code, notes, and snippets.

@Hayao0819
Last active January 15, 2022 05:29
Show Gist options
  • Save Hayao0819/80c242f65a3b195f8fa99a3da1a12981 to your computer and use it in GitHub Desktop.
Save Hayao0819/80c242f65a3b195f8fa99a3da1a12981 to your computer and use it in GitHub Desktop.
正弦波を点で表示
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
from fractions import Fraction as fract
# from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=[16,9])
x = np.linspace(0, 2*np.pi, 1000)
def plot(data):
plt.cla()
plt.yticks(np.arange(-1, 1, step=0.05))
plt.ylim(-1,1)
for _cnt in range(100):
alpha = 2*np.pi*0.1*data-fract(1,10)*_cnt
y = np.sin(alpha)
plt.scatter(_cnt, y)
ani = animation.FuncAnimation(fig, plot, interval=10)
ani.save("test.gif", writer = 'imagemagick')
#plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment