I was trying the tutorial posted on http://queirozf.com/entries/pandas-dataframe-plot-examples-with-matplotlib-pyplot and was wondering whether it was possible to have a bar chart created that could have colored columns.
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({
'name':['john','mary','peter','jeff','bill','lisa','jose'],
'age':[23,78,22,19,45,33,20],
'gender':['M','F','M','M','M','F','M'],
'state':['california','dc','california','dc','california','texas','texas'],
'num_children':[2,0,0,3,2,1,4],
'num_pets':[5,1,0,5,2,2,3]
})
df.plot(kind='bar',x='name',y='age')
the current code above creates
.
However, I would like to have the eventual output showing that the columns have a different
.
(The column showing John would be red, Mary would be orange and so on)
Any and all help is appreciated! Thank you.