1 import pandas
2 from matplotlib import pyplot
3
4 #设置中文字体
5 pyplot.rcParams['font.sans-serif']=['simhei'] #显示中文标签
6 pyplot.rcParams['axes.unicode_minus']=False
7
8 excel=pandas.read_excel('填充日期.xlsx')
9 excel.sort_values(by='score1',ascending=False,inplace=True)
10
11 #开始绘制柱状图
12 #excel.plot.bar(x='name',y='score',color='orange',title='score')
13 pyplot.bar(excel.name,excel.score1,color='orange')
14 pyplot.xticks(excel.name,rotation=45)
15 pyplot.yticks(excel.score1,rotation=45)
16
17 #设置x,y标签
18 pyplot.xlabel('姓名',fontweight='bold')
19 pyplot.ylabel('分数',fontweight='bold')
20
21
22 pyplot.tight_layout() #紧凑放置
23 pyplot.show()