0
0
Matplotlibdata~30 mins

Cumulative histograms in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Cumulative histograms
📖 Scenario: You are analyzing the daily sales numbers of a small store over a week. You want to understand how sales accumulate over the days.
🎯 Goal: Create a cumulative histogram using matplotlib to visualize the accumulation of sales over the week.
📋 What You'll Learn
Create a list called daily_sales with exact sales numbers for 7 days
Create a variable called bins to define histogram bins
Use plt.hist() with cumulative=True to create a cumulative histogram
Display the histogram with plt.show()
💡 Why This Matters
🌍 Real World
Cumulative histograms help businesses see how quantities add up over time or categories, like total sales or accumulated customers.
💼 Career
Data analysts and scientists use cumulative histograms to understand trends and distributions in data for better decision-making.
Progress0 / 4 steps
1
Create the daily sales data
Create a list called daily_sales with these exact values: 5, 8, 6, 10, 7, 9, 4 representing sales for 7 days.
Matplotlib
Need a hint?

Use square brackets [] to create a list and separate numbers with commas.

2
Define histogram bins
Create a variable called bins and set it to a list with these exact values: 0, 3, 6, 9, 12 to define the histogram bins.
Matplotlib
Need a hint?

Bins are the edges for grouping data in the histogram. Use a list with the exact numbers.

3
Create the cumulative histogram
Import matplotlib.pyplot as plt. Then use plt.hist() with daily_sales, bins, and cumulative=True to create a cumulative histogram.
Matplotlib
Need a hint?

Use import matplotlib.pyplot as plt to import. Then call plt.hist() with the right arguments.

4
Display the histogram
Use plt.show() to display the cumulative histogram plot.
Matplotlib
Need a hint?

Call plt.show() to open the plot window and see the histogram.