我的箱线图似乎与绘图的x轴刻度不对齐。如何使箱线图与x轴刻度对齐?
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
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()
hue='label', hue_order=label_list
,这会导致条形图发生偏移。 - ImportanceOfBeingErnest