【发布时间】:2019-04-01 10:43:08
【问题描述】:
数据格式如下:
first_name nick_name activity duration
Harish Escorts MC GUARD ASSEMBLY WITH CABINATE BRACKET 226
Harish Escorts COOLANT TANK AND SIDE DOORS, OPP DOORS 225
Narasaraj Escorts MC GUARD ASSEMBLY WITH CABINATE AND BRACKET MO 225
Narasaraj Escorts COOLANT TANK AND SIDE DOORS, OPP DOORS ASSEMBLY 150
PurushothamEscorts PNEUMATIC AND LUBRICATION ASSEMBLY 55
Shivu Escorts CABLE CARRIER AND AXIS MOTOR ASSEMBLY 123
使用 seaborn 我正在做一个条形图:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="ticks", color_codes=True)
df = pd.read_excel('VMC & HMC data (sep&oct-15).xlsx', index = False)
df1 = df1[[ "first_name" , "nick_name", "activity" , "duration"]]
g = sns.catplot(x= 'first_name', y = 'duration', hue = 'activity' , data = df1, kind = 'bar', dodge=False, palette="deep", ci = None)
plt.ylim(0,300)
plt.gcf().autofmt_xdate()
for index, row in df1.iterrows():
g.text(row.name,row.first_name,row.duration, color='black', ha="center")
它给我带来了错误:
AttributeError: 'FacetGrid' object has no attribute 'text'
【问题讨论】:
-
@jezrael 请看看我的问题 :)
标签: python-2.7 pandas plot bar-chart seaborn