importpandasaspdimportmatplotlib.pyplotaspltif__name__=='__main__':students=pd.read_excel("C:/Users/123/Desktop/pandas/010_叠加柱状图_水平柱状图/Students.xlsx")print(students.head)#排序:倒序students.sort_values(by=["2017","2016"],inplace=True,ascending=False)print(students.head)#方法一students.plot.bar(x="Field",y=["2017","2016"],color=["orange","red"],title="internationalStudentsbyField")plt.title("InternationalStudentsbyField",fontsize=16,fontweight="bold")#设置titleplt.xlabel("Fieled",fontweight="bold")#x轴名称plt.ylabel("Number",fontweight="bold")#y轴名称#设置文字-对齐ax=plt.gca()ax.set_xticklabels(students['Field'],rotation=45,ha="right")plt.tight_layout()#显示标签完整#显示图片plt.show()
THE END