import pandas as pd
import matplotlib.pyplot as plt
students=pd.read_excel('c:/Temp/Students.xlsx')
students.sort_values(by = 'Number',inplace= True ,ascending= False)
#sort_values 排序
#以Numberi排序
# inplace=True:不创建新的对象,直接对原始对象进行修改;
# inplace=False:对数据进行修改,创建并返回新的对象承载其修改结果
# ascending是否正序排
students.plot.bar(x='Field',y='Number',color='orange',title= "intertional students field") #Field为 x轴 Number为Y轴
print (students)
plt.show() #展示图
import pandas as pd
import matplotlib.pyplot as plt
students=pd.read_excel('c:/Temp/Students.xlsx')
students.sort_values(by = 'Number',inplace= True ,ascending= False)
#sort_values 排序
#以Numberi排序
# inplace=True:不创建新的对象,直接对原始对象进行修改;
# inplace=False:对数据进行修改,创建并返回新的对象承载其修改结果
# ascending是否正序排
# students.plot.bar(x='Field',y='Number',color='orange',title= "intertional students field") #Field为 x轴 Number为Y轴
plt.bar(students.Field,students.Number,color='orange')
plt.xticks(students.Field,rotation='90') #Field 标签旋转90
print (students)
plt.xlabel('Field')
plt.ylabel('Number')
plt.title('intertional students field',fontsize=16)
#x轴名称,y轴名称,标题及字号
plt.tight_layout() #紧凑型视图
plt.show() #展示图