Sorting the x axis in matplotlib

Viewed 21080

Why does this code not plot the x-axis sorted by 'value'?

import pandas as pd
import matplotlib.pyplot as plt

# creating dataframe
df=pd.DataFrame()
df['name'] = [1,2,3]
df['value'] = [4,3,5]

# sorting dataframe
df.sort_values('value', ascending = False, inplace= True)

# plot
plt.scatter(df['value'],df['name'])
plt.show()
1 Answers
Related