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()
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/137690.html
標籤:Python
上一篇:向excel中插入柱狀圖
下一篇:往excel中插入分組柱狀圖
