柱状图、水平柱状图

import pandas as pd
import matplotlib.pyplot as plt

users=pd.read_excel('c:/Temp/Users.xlsx')
users['Total'] = users['Oct']+users['Nov'] + users['Dec'] #创建Total列

users.sort_values(by = 'Total',inplace= True ,ascending=False)  #排序

print(users)

# users.plot.bar(x='Name',y=['Oct','Nov','Dec'],stacked =True ,title='User Behavior')
users.plot.barh(x='Name',y=['Oct','Nov','Dec'],stacked =True ,title='User Behavior') #水平叠加柱状图
plt.tight_layout()
plt.show()

 

posted @ 2019-06-10 15:20  Inserence  阅读(470)  评论(0编辑  收藏  举报