0
0
Matplotlibdata~30 mins

Storytelling with visualization sequence in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Storytelling with visualization sequence
📖 Scenario: You are a data analyst working for a small bakery. You have sales data for three types of pastries over a week. Your manager wants to see a clear story of how each pastry sold each day, so they can decide what to bake more of next week.
🎯 Goal: Create a sequence of visualizations using matplotlib to show daily sales of three pastries. Start by setting up the data, then configure the days, plot the sales for each pastry, and finally display the combined chart to tell the sales story clearly.
📋 What You'll Learn
Use a dictionary to store sales data for three pastries: Croissant, Muffin, and Danish.
Create a list of days representing a week.
Plot a line chart for each pastry's sales over the days using matplotlib.
Display the final combined plot with a legend and labels.
💡 Why This Matters
🌍 Real World
Visualizing sales data helps businesses understand trends and make better decisions about inventory and marketing.
💼 Career
Data analysts and business intelligence professionals often create clear visual stories from data to communicate insights to managers and stakeholders.
Progress0 / 4 steps
1
DATA SETUP: Create sales data dictionary
Create a dictionary called sales with these exact entries: 'Croissant': [20, 22, 18, 25, 30, 28, 35], 'Muffin': [15, 18, 14, 20, 22, 25, 27], and 'Danish': [10, 12, 9, 15, 18, 20, 22].
Matplotlib
Need a hint?

Use a dictionary with pastry names as keys and lists of daily sales as values.

2
CONFIGURATION: Create list of days
Create a list called days with these exact values: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].
Matplotlib
Need a hint?

Use a list with the exact day abbreviations as strings.

3
CORE LOGIC: Plot sales lines for each pastry
Import matplotlib.pyplot as plt. Use a for loop with variables pastry and sales_list to iterate over sales.items(). Inside the loop, plot days on the x-axis and sales_list on the y-axis with label=pastry.
Matplotlib
Need a hint?

Remember to import matplotlib.pyplot as plt before plotting.

Use a for loop to plot each pastry's sales with labels.

4
OUTPUT: Display the final plot with labels and legend
Add x-axis label 'Day' and y-axis label 'Number Sold' using plt.xlabel() and plt.ylabel(). Add a title 'Pastry Sales Over a Week' with plt.title(). Show the legend with plt.legend(). Finally, display the plot with plt.show().
Matplotlib
Need a hint?

Use plt.xlabel(), plt.ylabel(), plt.title(), plt.legend(), and plt.show() to complete the plot.