我敢肯定这应该很容易,但是我无法从seaborn文档中找到如何特别选择要显示的x标签分类变量的顺序?
我每周有以下几个小时的工作时间,但我想在我的x轴上从0-10、11-20、21-30、31-40和超过40小时订购这些时间。我怎样才能做到这一点?
def hours_per_week (x):
if x < 11: return '0-10 hours'
elif x < 21: return '11-20 hours'
elif x < 31: return '21-30 hours'
elif x < 41: return '31-40 hours'
else: return 'More than 40 hours'
Run Code Online (Sandbox Code Playgroud)
这是我绘制图表的最原始代码。注收入猫'是人挣分类分组50K下的人与收入以上50K
plot_income_cat_hours = sns.countplot(x='hours_per_week_grouping',
hue='income-cat', data=data)
Run Code Online (Sandbox Code Playgroud)