我已使用以下代码在 seaborn 中设置 xticks,但这不起作用。我的 xticks 标签来自一个列表,并且它们已经正确排序。
[i[0] for i in jobs]
['admin.',
'blue-collar',
'entrepreneur',
'housemaid',
'management',
'retired',
'self-employed',
'services',
'student',
'technician',
'unemployed',
'unknown']
plt.figure(figsize=(7,3))
g = sns.countplot(x='job', y=None, data=df)
plt.title("Attempts by Job")
g.set(xticks=[i[0] for i in jobs])
#plt.xticks = jobs
plt.show()
~/anaconda2/envs/py36/lib/python3.6/site-packages/matplotlib/category.py in convert(value, unit, axis)
63
64 # force an update so it also does type checking
---> 65 unit.update(values)
66
67 str2idx = np.vectorize(unit._mapping.__getitem__,
AttributeError: 'NoneType' object has no attribute 'update'