轴互相碰碰,set_xticklabels不起作用

时间:2018-10-08 00:15:33

标签: python graph seaborn

下面是我的代码。 x标签不会旋转。

bins=pd.cut(df_train['Fare'],[0,5,10,15,20,30,40,50,100,250,500])
age=df_train.groupby(bins)['Survived'].agg(['mean'])
g=sns.barplot(x='Fare', y='mean',data=age.reset_index(), color='b')
g.set_xticklabels(rotation=30)

enter image description here

错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-169-395f6cf89c4c> in <module>()
      2 age=df_train.groupby(bins)['Survived'].agg(['mean'])
      3 g=sns.barplot(x='Fare', y='mean',data=age.reset_index(), color='b')
----> 4 g.set_xticklabels(rotation=30)

TypeError: set_xticklabels() missing 1 required positional argument: 'labels'

0 个答案:

没有答案