import numpy as np
import cv2
data = [1, 5, 3, 9 ,4] # fill in your data
size = 200, 300, 3
hist = np.zeros(size, dtype=np.uint8) + 255
interval = hist.shape[1] / (len(data) + 1)
width = interval * 0.7
max_height = hist.shape[0] * 0.9
max_data = max(data)
interval_count = 1
for value in data:
height = max_height / max_data * value
pt1 = (int(interval_count * interval - width / 2), int(hist.shape[0] - height))
pt2 = (int(interval_count * interval + width / 2), int(hist.shape[0]))
cv2.rectangle(hist, pt1, pt2, (255, 0, 0), -1)
interval_count += 1
cv2.imwrite("hist.jpg", hist)