df.groupby(['Id']).median().sort_values("Speed").plot.bar()或在汇总它们后尝试sort_values(“ Speed”)。
编辑:所以您需要这样做:
result = a.groupby(["Id"])['Speed'].aggregate(np.median).reset_index().sort_values('Speed')并在sns.barplot中添加顺序:
sns.barplot(x='Id', y="Speed", data=a, palette=colors, order=result['Id'])



