0

I have this dataframe

enter image description here

I try to show graph by this code

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

it's give me this results

enter image description here

I try to order by desc with this code

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

look like it's not work, I tried some solutions but it's still not work.

solution or code guiding for order by desc in this graph.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

1 Answers1

1

Simply sort your dataframe before plotting:

africa_all_percent = africa_all_percent.sort_values('suicide_percent_for_all_pop', ascending=False)

Output:

enter image description here

Tranbi
  • 11,407
  • 6
  • 16
  • 33