Why Bar Charts Compare Categories
📖 Scenario: Imagine you run a small bakery. You want to see which types of cakes sell the most each day. You have sales numbers for three cake types: Chocolate, Vanilla, and Strawberry.
🎯 Goal: You will create a bar chart to compare the sales of these cake types. This will help you see which cake is the most popular at a glance.
📋 What You'll Learn
Create a dictionary called
cake_sales with exact entries: 'Chocolate': 30, 'Vanilla': 45, 'Strawberry': 25Create a list called
categories that contains the keys from cake_salesCreate a list called
sales that contains the values from cake_salesUse
matplotlib.pyplot to create a bar chart with categories on the x-axis and sales on the y-axisAdd a title to the chart:
'Cake Sales Comparison'Label the x-axis as
'Cake Type' and the y-axis as 'Number Sold'Display the bar chart
💡 Why This Matters
🌍 Real World
Bar charts help businesses quickly compare sales or counts across different categories, like product types or customer groups.
💼 Career
Data analysts and scientists use bar charts to communicate insights clearly to teams and decision makers.
Progress0 / 4 steps