ヒストグラムを描くには、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:// …
matplotlib で、グラフのタイトルに上付き文字を入力する方法
数学記号などで、グラフのタイトルに上付きの文字を入力したい場合がある。 その場合は次のように書いて設定できる。 例 import numpy as np from matplotlib import …
items() で辞書から要素を取り出し、random.choice でランダムに要素を選択する。 例 import random # 県庁所在地 mydict = {‘宮城県’:’仙台市’,’茨城県 …
matplotlib で、x,y の軸上の数値を表示する方法
ax の xtics と ytics を使って表示する。 詳細は次のドキュメントを参照。 https://matplotlib.org/stable/gallery/lines_bars_and_ma …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。