teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

2019/01/30 14:24

投稿

kouheichild
kouheichild

スコア18

title CHANGED
File without changes
body CHANGED
@@ -3,11 +3,13 @@
3
3
  pythonでヒストグラムが動くアニメーションを作りたいです.
4
4
  具体的には,平均15,標準偏差2(固定)で平均が15から0に移動するアニメーションを作りたいです.
5
5
  下記のコードを実行したのですが、静止画になってしまい、うまくアニメーションが作成できません.
6
- 大変恐縮ですが,ご教授お願いいたします.
7
6
 
8
7
 
8
+ https://qiita.com/yubais/items/c95ba9ff1b23dd33fde2
9
+ また記載したコードは、上記のページに記載されたコードを参考にしました。このページに記載されたコードを流した場合はアニメーションが作動します。
9
10
 
11
+ 大変恐縮ですが,ご教授お願いいたします.
10
- ### 該当のソースコード
12
+ ## 該当のソースコード
11
13
 
12
14
  ```python
13
15
  import numpy as np

1

2019/01/30 14:24

投稿

kouheichild
kouheichild

スコア18

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  pythonでヒストグラムが動くアニメーションを作りたいです.
4
4
  具体的には,平均15,標準偏差2(固定)で平均が15から0に移動するアニメーションを作りたいです.
5
- うまくアニメーションが作成できません.
5
+ 下記のコードを実行たのですが、静止画になってまい、うまくアニメーションが作成できません.
6
6
  大変恐縮ですが,ご教授お願いいたします.
7
7
 
8
8
 
@@ -14,16 +14,17 @@
14
14
  import matplotlib.pyplot as plt
15
15
  import matplotlib.animation as animation
16
16
  from scipy import stats
17
+
17
18
  fig = plt.figure()
18
-
19
+ ims=[]
19
- a = np.linspace(start=15,stop=0,num=16)
20
+ a =np.linspace(start=15,stop=0,num=16)
20
21
  for i in a:
21
22
  np.random.seed(1)
22
23
  rand = stats.norm.rvs(i,2,7321)
23
- im = plt.hist(rand,)
24
+ im = plt.hist(rand)
24
25
  ims.append(im)
25
26
 
26
- # 16枚のプロットを 100ms ごとに表示
27
+ # 16枚のプロットを 1000ms ごとに表示
27
28
  ani = animation.ArtistAnimation(fig, ims, interval=1000)
28
29
  plt.show()
29
30