Reputation: 8025
I want to superimpose 2 bar plots with same x-xis. I have a dataframe with this data:
df = pd.DataFrame({'a':[1,2,3,1,2,2,2],
'b':[1,1,1,3,2,2,2]})
I can plot 2 histogram plots for a and b:
df['a'].value_counts().plot(kind = 'bar')
df['b'].value_counts().plot(kind = 'bar')
How can i superimpose one of them on the other ?
Example of an unrelated chart format that im looking for:
Upvotes: 2
Views: 3126
Reputation: 153460
Use width
and ax
paramters:
ax = df['a'].value_counts().plot(kind='bar', color='blue', width=.75, legend=True, alpha=0.8)
df['b'].value_counts().plot(kind='bar', color='maroon', width=.5, alpha=1, legend=True)
Output:
Upvotes: 2