Doubt Dhanabalu
Doubt Dhanabalu

Reputation: 457

how to order the bars in the order as they receive in matplotlib in python?

How to order the bars in the frequency plot in the order of 0,1,2,3,4 instead of the highest frequency as shown in the below picture?

enter image description here

This is the code i used:

train_df.Fedu.value_counts().plot(kind='bar', alpha=0.6)
plt.title("Distribution of Father's  education")

Upvotes: 1

Views: 165

Answers (1)

Scott Boston
Scott Boston

Reputation: 153540

Use sort_index:

train_df.Fedu.value_counts().sort_index().plot(kind='bar')

enter image description here

Upvotes: 2

Related Questions