0
0
Matplotlibdata~30 mins

Area chart with plt.fill_between in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Area chart with plt.fill_between
📖 Scenario: You are analyzing the sales data of a small shop over a week. You want to visualize how sales changed each day using an area chart. This will help you see the trend clearly.
🎯 Goal: Create an area chart using matplotlib with plt.fill_between to show daily sales over one week.
📋 What You'll Learn
Create a list called days with the days of the week as strings: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'.
Create a list called sales with the sales numbers: 150, 200, 180, 220, 170, 210, 190.
Use plt.fill_between to create the area chart with days on the x-axis and sales on the y-axis.
Add labels for the x-axis and y-axis, and a title for the chart.
Display the chart using plt.show().
💡 Why This Matters
🌍 Real World
Area charts are useful to show how values change over time or categories, like sales, temperatures, or website visits.
💼 Career
Data analysts and scientists use area charts to communicate trends clearly to teams and decision makers.
Progress0 / 4 steps
1
Create the sales data lists
Create a list called days with these exact values: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'. Then create a list called sales with these exact values: 150, 200, 180, 220, 170, 210, 190.
Matplotlib
Need a hint?

Use square brackets to create lists. Put the days as strings in the days list and numbers in the sales list.

2
Import matplotlib and set up the plot
Import matplotlib.pyplot as plt. This will allow you to create the chart.
Matplotlib
Need a hint?

Use import matplotlib.pyplot as plt to import the plotting library.

3
Create the area chart with plt.fill_between
Use plt.fill_between with days as the x-axis and sales as the y-axis to create the area chart. Then add x-axis label 'Day', y-axis label 'Sales', and title 'Sales Over a Week'.
Matplotlib
Need a hint?

Use plt.fill_between with numeric x values and then set x-ticks to the day labels. Then use plt.xlabel, plt.ylabel, and plt.title to add labels and title.

4
Display the area chart
Use plt.show() to display the area chart you created.
Matplotlib
Need a hint?

Use plt.show() to display the chart window.