Seaborn Bar Horizontal,按列的 DESC 值绘制顺序

问题描述 投票:0回答:0

我有这个数据框 enter image description here 我尝试用这段代码显示图表

sns.barplot(data=africa_all_percent,y="country", x="suicide_percent_for_all_pop",palette='plasma',orient="h")

它给我这个结果

enter image description here

我尝试使用此代码按描述顺序订购

orderX = africa_all_percent['suicide_percent_for_all_pop'].sort_values(ascending=False)

sns.barplot(data=africa_all_percent,y="country", x="suicide_percent_for_all_pop",palette='plasma',orient="h",order = orderX)

enter image description here 看起来它不起作用,我尝试了一些解决方案但它仍然不起作用。

order by desc in this graph 的解决方案或代码指导。

python jupyter-notebook seaborn visualization kaggle
© www.soinside.com 2019 - 2024. All rights reserved.