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

回答編集履歴

2

説明の改善

2019/01/06 05:54

投稿

hayataka2049
hayataka2049

スコア30939

answer CHANGED
@@ -17,7 +17,7 @@
17
17
  >
18
18
  > [matplotlib.pyplot.text — Matplotlib 3.0.2 documentation](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.text.html)
19
19
 
20
- 位置引数の`x`,`y`,`s`は必ず与える必要があります。`x`と`y`が座標で、`s`が表示したい文字列です。
20
+ 最低限、位置引数の`x`,`y`,`s`は与える必要があります。`x`と`y`が座標で、`s`が表示したい文字列です。
21
21
 
22
22
  さて`plt.hist`でどうこれらの情報を取得するかですが、実は返り値として戻ってくるので、それが使えます([matplotlib.pyplot.histのドキュメント](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html)のReturns:以下参照)。
23
23
 
@@ -27,7 +27,7 @@
27
27
  import matplotlib.pyplot as plt
28
28
 
29
29
  n, bins, _ = plt.hist(np.random.normal(size=1000))
30
- xs = (bins[:-1] + bins[1:])/2 # 各柱の端が返るので平均して真ん中にする
30
+ xs = (bins[:-1] + bins[1:])/2 # 各柱の端が返るので1つずらして足して2で割ることで真ん中にする
31
31
  ys = n
32
32
  for x, y in zip(xs, ys):
33
33
  plt.text(x, y, str(y), horizontalalignment="center")

1

修正

2019/01/06 05:54

投稿

hayataka2049
hayataka2049

スコア30939

answer CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
  位置引数の`x`,`y`,`s`は必ず与える必要があります。`x`と`y`が座標で、`s`が表示したい文字列です。
21
21
 
22
- さて`plt.hist`でどうこれらの情報を取得するかですが、実は返り値として戻ってくるので、それが使えます(ドキュメントのReturns:以下参照)。
22
+ さて`plt.hist`でどうこれらの情報を取得するかですが、実は返り値として戻ってくるので、それが使えます([matplotlib.pyplot.histのドキュメント](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html)のReturns:以下参照)。
23
23
 
24
24
 
25
25
  ```python