Home > OS >  Custom Sorting gglot2 in python
Custom Sorting gglot2 in python

Time:12-05

I am working on ggplt visualization, which plotting countries total expenditure from the highest to the lowest. Since there are many small values, I am aggregating several small categories into the "other" category. I am having trouble finding a way to move the "Other" Category to the end and keeping the rest sorted from in descending order

`

ggplot(df_sorted, aes(x = 'reorder(customer_country, Total_Expenditure, fun=sum)', y = 'Total_Expenditure', fill='Total_Expenditure'))\
      geom_bar(stat="identity")\
          scale_x_discrete()\
              coord_flip()\
                 scale_fill_cmap(cmap_name="RdYlGn")

`

enter image description here

  • Related