1

I have some data that I would like to plot, visualizing in a normalized chart. Dataset:

            Gini
    var1    0.000223
    var2    0.000047
    var3    0.000933
    var4    0.000081
    var5    0.000014

df.sort_values(by='Gini', ascending=False).plot(kind='bar')

I have tried with plt.yticks(np.arange(0, 1)) but this just changes the scale.

0

1 Answer 1

2

If you're having a single column and plotting only the "Gini" column, you can select that column and normalize it before plotting it like:

((df['Gini']-df['Gini'].min())/(df['Gini'].max()-df['Gini'].min())).sort_values().plot(kind='bar')

In general, you can normalize the whole dataframe and plot it:

df_normalized = (df-df.min())/(df.max()-df.min())
df_normalized.sort_values(by='Gini', ascending=False).plot(kind='bar')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.