我有什么
列
'Month Joined'
作为 int64
列
'Years To Join'
作为 int64
month_order
:['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
我想要什么
我想创建一个箱线图并将
xticks
从列表中的数字更改为月份名称。我使用这个代码:
sns.boxplot(
x = companies['Month Joined'],
y = companies['Years To Join'],
showfliers = False,
order = month_order
)
却什么也没得到:
但是当我删除
order = month_order
时,一切正常(除了月份的名称是数字)
想要的结果
问题
如何解决这个问题并获得想要的结果?
使用 set_xticks()
尝试一下fig, ax = plt.subplots()
sns.boxplot(
x = companies['Month Joined'],
y = companies['Years To Join'],
showfliers = False,
order = month_order,
ax=ax
)
ax.set_xticks(month_order)