#plt.figure(figsize=(15,5))
bins=[0,10,20,30,40,50]
ax=plt.title('SEM-2 adv-c Marks wise clasification', fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
ax=plt.xlabel('Marks',fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
ax=plt.ylabel('Total Students',fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
ax=plt.hist(sem2.ADV_C,bins, color='r', density=False, label='No of Student')
plt.legend()
plt.show()
我想显示每个小节的编号以了解什么是分类编号
平均每个条带的左右边界会在每个条形的中心给出刻度位置。带有左右边界的标签可以放在此处:
from matplotlib import pyplot as plt
import numpy as np
bins = np.array([0, 10, 20, 30, 40, 50])
# create sum dummy data
sem2_ADV_C = (np.random.beta(4, 3, 500) * 50).astype(np.int)
plt.title('SEM-2 adv-c Marks wise clasification', fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
plt.xlabel('Marks', fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
plt.ylabel('Total Students', fontdict={'fontname': 'Sans Serif', 'fontsize': 15})
plt.hist(sem2_ADV_C, bins, color='crimson', density=False, label='No of Student', edgecolor='black')
plt.xticks((bins[:-1] + bins[1:]) / 2, [f'{b0}–{b1}' for b0, b1 in zip(bins[:-1], bins[1:])])
plt.show()