ヒストグラムを描くには、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
関連記事
python の __str__ と __repr__ とは
python でクラスの情報を文字列で表示するとき、__str__ メソッドと __repr__ メソッドが使える。__str__ は、プログラマーとは限らないユーザーに「読める形で情報を表示」するこ …
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。
リストを iter に変えたあと、… next() を使う。 参考リンク https://www.programiz.com/python-programming/methods/buil …
python3 で csv ファイルを読み込んで、最初の数行を表示する方法
以下の例では、空の配列 data を用意しておき、最初の3行を読み込んでおく。 例 import csv with open(‘data.csv’,’r’) as csv_file: csv_read …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。