สร้าง histogram จาก list ข้อมูล
ใช้เมธอด hist() วาด histogram จากข้อมูล list
ขั้นตอน
- สร้าง list ข้อมูล (x data points)
- วาด histogram ด้วย hist()
- แสดงด้วย show()
ตัวอย่างโค้ด
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [[300, 400, 500, 2000, 10],
[300, 400, 500, 2000, 10],
[300, 400, 500, 2000, 10],
[300, 400, 500, 2000, 10],
[300, 400, 500, 2000, 10]]
plt.hist(x, 10)
plt.show()
ผลลัพธ์
