Check out Kite (free AI Coding Assistant) → Link



Buy Me a Coffee? Your support is much appreciated!

PayPal Me: https://www.paypal.me/jiejenn/5
Venmo: @Jie-Jenn

Source Code:  

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_excel('data.xlsx', sheet_name='Data', engine='openpyxl')
data_points = df['Points'].tolist()
n_bins = 10

fig, ax = plt.subplots()

arr = ax.hist(data_points, ec='white', bins=n_bins)

plt.xticks(range(0, 101, n_bins))

labels = [arr[0][i] for i in range(len(arr[0]))]

ax.set_ylim(0, max(labels) + 10)

rects = ax.patches

for rect, label in zip(rects, labels):
    height = rect.get_height()
    ax.text(
        rect.get_x() + rect.get_width() / 2,
        height + 0.01,
        int(label),
        ha='center',
        va='bottom'
    )

plt.title('Histogram Demo')
plt.show()