回答編集履歴
1
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
※ 以下、アニメーションをGIFファイルに保存するだけのものです
|
1
|
+
※ 以下、アニメーションをGIF形式のファイルに保存するだけのものです
|
2
2
|
```python
|
3
3
|
import numpy as np
|
4
4
|
import matplotlib.animation as ani
|
@@ -6,21 +6,21 @@
|
|
6
6
|
|
7
7
|
def animate2(i): #IR用グラフ更新関数
|
8
8
|
ax2.plot(g_IR_x[:i], g_IR[:i], 'b')
|
9
|
-
ax2.set_title(f't= {i
|
9
|
+
ax2.set_title(f't= {i*tick:.2f}')
|
10
10
|
|
11
|
-
N = 5000
|
11
|
+
N, tick = 5000, 20
|
12
|
-
g_IR = np.arange(N)
|
12
|
+
g_IR_x = np.arange(0, N, tick)
|
13
|
+
g_IR = g_IR_x
|
13
14
|
fig = plt.figure() #描画の用意
|
14
15
|
ax2 = fig.add_subplot(111)
|
15
16
|
ax2.set_xlabel(r"$t$")#x軸のラベル
|
16
17
|
ax2.set_ylabel(r"Inertial radius $R$")#y軸のラベル
|
17
18
|
ax2.set_xlim(0, N)
|
18
19
|
ax2.set_ylim(0, N)
|
19
|
-
g_IR_x = np.arange(len(g_IR))
|
20
20
|
|
21
21
|
#tkinterのウインド上部にグラフを表示する
|
22
|
-
movie = ani.FuncAnimation(fig, animate2, interval=0.5,frames=
|
22
|
+
movie = ani.FuncAnimation(fig, animate2, interval=0.5,frames=range(len(g_IR_x))) #frames=ani_step
|
23
23
|
movie.save(f"ani.gif",writer='pillow')
|
24
24
|
```
|
25
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-11/98c5fcf9-3186-4e30-a069-1788b1413841.gif)
|
25
26
|
|
26
|
-
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-02-11/1a2985d7-e4ef-4750-9531-4b28896345f4.gif)
|