小编lem*_*n93的帖子

如何将seaborn boxplot与其x刻度居中对齐?

我的箱线图似乎与图的 x-tick 不一致。如何使箱线图与 x-tick 对齐?

df = pd.DataFrame([['0', 0.3],['1', 0.5],['2', 0.9],
                   ['0', 0.8],['1', 0.3],['2', 0.4],
                   ['0', 0.4],['1', 0.0],['2', 0.7]])

df.columns = ['label', 'score']

label_list = ['0', '1', '2']

fig = plt.figure(figsize=(8, 5))
g=sns.boxplot(x='label', y='score', data=df, hue='label', hue_order=label_list)
g.legend_.remove()

plt.show()

Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

python pandas seaborn

2
推荐指数
1
解决办法
1298
查看次数

标签 统计

pandas ×1

python ×1

seaborn ×1