回答編集履歴
1
d
answer
CHANGED
@@ -8,22 +8,23 @@
|
|
8
8
|
import seaborn as sns
|
9
9
|
from matplotlib.animation import FuncAnimation
|
10
10
|
from scipy import stats
|
11
|
-
#
|
11
|
+
# jupyter notebook の場合、コメントアウト
|
12
|
+
# %matplotlib nbagg
|
12
13
|
|
13
14
|
sns.set(style='ticks')
|
14
15
|
np.random.seed(42)
|
15
16
|
|
16
|
-
locs = np.linspace(15, 0, 16)
|
17
|
+
locs = np.linspace(15, 0, 16) # 平均
|
17
18
|
fig, ax = plt.subplots(figsize=(4, 4))
|
18
19
|
|
19
20
|
def plot(i, locs):
|
20
|
-
plt.cla()
|
21
21
|
data = stats.norm.rvs(loc=locs[i], scale=2, size=7321)
|
22
22
|
|
23
|
-
ax.clear()
|
23
|
+
ax.clear() # 図をクリア
|
24
|
+
# kde=False 密度関数描画しない、bins=50 ビンの数、norm_hist ヒストグラム正規化
|
24
25
|
sns.distplot(data, bins=50, ax=ax, kde=False, norm_hist=True)
|
25
26
|
# ax.hist(data) setborn 使わない場合はこっち
|
26
|
-
ax.set_ylim(0, 0.3)
|
27
|
+
ax.set_ylim(0, 0.3) # y 軸範囲固定
|
27
28
|
|
28
29
|
|
29
30
|
# 16枚のプロットを 1000ms ごとに表示
|