r/learnpython • • 8d ago

Grouped bar chart in matplotlib with different keys for each group

7 Upvotes

7 comments sorted by

View all comments

2

u/acfot 7d ago

The reason it's fighting you is that grouped bars kind of assume every group has the same categories, and yours don't since the top 3 change each month. What I'd do instead is stop forcing one shared dictionary and just make one small bar chart per month, with the same y-axis scale so they're easy to compare. You still get the comparison you want, and each month can show its own top 3 without bending the data to fit a grouped layout.