0

I it possible to have different colors on my barplot straight from pandas plot without specifying them. Here is what I am referring about: I have this dataframe:

 df
 Personnage    Puissance
 J. Wick        82
 J. Bond        72
 J. Bourne      85
 J. Rambo       91
 J. McLane      83

When I use df.plot(kind='bar') all my bars are blue.I would like to use an argument to get the different colors without manually specifying them.

Herc01
  • 610
  • 1
  • 8
  • 17

1 Answers1

0

Are you open to seaborn:

import seaborn as sns
sns.barplot(x='Personnage', y='Puissance', data=df)

Output:

enter image description here

With matplotlib, you can just loop the data:

for idx, row in df.iterrows():
    plt.bar(row['Personnage'], row['Puissance'])

and you get pretty much the same output with different alpha:

enter image description here

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74