Reputation: 353
This code gives the plot underneath. The plot is ordered alphabetical. How can I make the Y axis ordered desc or asc based on value of x axis (x axis are euro's in this case). Thanks!
'''
df.groupby(['Type']).sum()['Bedrag'].plot.barh(y='Type');
Upvotes: 0
Views: 128
Reputation: 1070
You can use the sort_values
function:
df.groupby(['Type']).sum()['Bedrag'].sort_values().plot.barh(y='Type')
You can pass the ascending
parameter to specify if you want to sort asc or desc:
...sort_values(ascending=True)
...sort_values(ascending=False)
Upvotes: 1