ヒストグラムを描くには、data_hist を使う。
ヒストグラムの縦棒の数は bins で指定する。
例
from matplotlib import pyplot as plt
data_hist = [25,26,27,27,20,21,20,28,29,40,25,21,21,41]
plt.hist(data_hist, bins=10, edgecolor='blue')
plt.show()
結果

雑記
投稿日:
ヒストグラムを描くには、data_hist を使う。
ヒストグラムの縦棒の数は bins で指定する。
from matplotlib import pyplot as plt
data_hist = [25,26,27,27,20,21,20,28,29,40,25,21,21,41]
plt.hist(data_hist, bins=10, edgecolor='blue')
plt.show()
執筆者:seyanen
関連記事
y軸に、2種類のグラフを異なるスケールでプロットする。 matplotlib axes の twinx() を使う。 https://matplotlib.org/stable/api/_as_gen …
python3 で、dictionary のキー一覧を取得する方法
dict.keys() でキーを取得することができる。 参考:dictionary の値一覧を取得するときは、dict.values() を使う。 例 print(dict.keys())
python3 でグローバル変数とローカル変数で同じ名前の変数を使う
グローバル変数とローカル変数で同じ名前の変数を使うことができる。 例 x = 10 def myfunc(): x = 20 print(‘関数内: x = ‘+str(x)) myfunc() pr …
ファイルを開くとき、「a+」を指定することで、data.txt というファイルを書き込みモードで開く。(もしファイルが存在していなければ作成する。) 例 f = open(‘data.txt’, ‘a …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。