setting spacing between grouped bar plots in matplotlib

Actually I think this problem is best solved by adjusting figsize and width; here is my output with figsize=(2,7) and width=0.3:

enter image description here

By the way, this type of thing becomes a lot simpler if you use pandas wrappers (i’ve also imported seaborn, not necessary for the solution, but makes the plot a lot prettier and more modern looking in my opinion):

import pandas as pd        
import seaborn 
seaborn.set() 

df = pd.DataFrame(groups, index=group_labels)
df.plot(kind='bar', legend=False, width=0.8, figsize=(2,5))
plt.show()

enter image description here

Leave a Comment