Grouped Bar Charts
📖 Scenario: You work in a small store that sells two types of fruits: apples and oranges. You want to compare the sales of these fruits over three months to see which fruit sold better each month.
🎯 Goal: Create a grouped bar chart to visually compare the monthly sales of apples and oranges side by side.
📋 What You'll Learn
Create a dictionary called
sales with keys as months and values as another dictionary with keys 'apples' and 'oranges' and their sales numbers.Create a list called
months containing the months in order.Create a variable called
bar_width to set the width of each bar.Use
matplotlib.pyplot to plot grouped bars for apples and oranges for each month.Add labels for the x-axis, y-axis, and a title for the chart.
Add a legend to distinguish apples and oranges.
💡 Why This Matters
🌍 Real World
Grouped bar charts help compare multiple categories across different groups, like sales of different products over months.
💼 Career
Data analysts and scientists use grouped bar charts to visualize and communicate comparisons clearly to stakeholders.
Progress0 / 4 steps