0
0
Matplotlibdata~30 mins

Normalized histograms in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Normalized histograms
📖 Scenario: You are analyzing the heights of a group of people. You want to see how the heights are spread out using a histogram. But instead of just counting how many people fall into each height range, you want to see the relative frequency so you can compare it easily with other groups.
🎯 Goal: Create a normalized histogram of the heights data using matplotlib. This means the histogram bars will show proportions instead of counts.
📋 What You'll Learn
Create a list called heights with exact values
Create a variable called bins to set the number of bins
Use matplotlib's hist() function with density=True to create a normalized histogram
Display the histogram with plt.show()
💡 Why This Matters
🌍 Real World
Normalized histograms help compare data distributions fairly, especially when sample sizes differ. For example, comparing heights of people from different cities.
💼 Career
Data scientists use normalized histograms to visualize and compare data distributions clearly, which helps in making data-driven decisions.
Progress0 / 4 steps
1
Create the heights data
Create a list called heights with these exact values: 160, 165, 170, 160, 175, 180, 170, 165, 160, 175.
Matplotlib
Need a hint?

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

2
Set the number of bins
Create a variable called bins and set it to 5 to divide the heights into 5 groups.
Matplotlib
Need a hint?

Just assign the number 5 to the variable bins.

3
Create the normalized histogram
Import matplotlib.pyplot as plt. Then use plt.hist() with the heights list and bins variable. Set density=True to normalize the histogram.
Matplotlib
Need a hint?

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

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

Call plt.show() to see the histogram window.