Created
January 15, 2022 05:28
-
-
Save Hayao0819/59846d51b1aba96e49831894cd5dc879 to your computer and use it in GitHub Desktop.
正弦波を点で正負2つ表示
This file contains hidden or 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
| #!/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) | |
| 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