Stacked Bar Charts
📖 Scenario: You work for a small company that sells three types of products: Books, Games, and Electronics. You want to show how many units of each product were sold in the first three months of the year.
🎯 Goal: Create a stacked bar chart using matplotlib to visualize the monthly sales of each product. Each bar will represent a month, and the segments in the bar will show sales of Books, Games, and Electronics stacked on top of each other.
📋 What You'll Learn
Create lists for months and sales of each product
Create a variable for the width of the bars
Use
plt.bar to plot stacked bars for Books, Games, and ElectronicsDisplay the final stacked bar chart with labels and legend
💡 Why This Matters
🌍 Real World
Stacked bar charts help businesses compare multiple categories over time or groups, making it easier to see total and individual contributions.
💼 Career
Data analysts and scientists use stacked bar charts to present sales, survey results, or any grouped data clearly to stakeholders.
Progress0 / 4 steps