ヒストグラムを描くには、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
関連記事
matplotlib のグラフ作成と gnuplot との対応 比較
起動方法 gnuplot コマンドで $ gnuplot とすれば起動できる。 初期設定ファイルは gnuplotrc にある。 gnuplotrc の場所の見つけ方(macの場合) https:// …
y軸に、2種類のグラフを異なるスケールでプロットする。 matplotlib axes の twinx() を使う。 https://matplotlib.org/stable/api/_as_gen …
python におけるシフト演算子(<< と >> )の使い方
32 = 2^5 なので、 << 1 とすると数値は2倍され、 >> 1 とすると数値が2分の1となる。 例 print(32 << 0) print(32 << …
matplotlib で折れ線グラフの下部に色をつけて塗りつぶす方法
pyplot の fill_between を使う。 例 from matplotlib import pyplot as plt data_x = [25,26,27] data_y = & …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。