0
0
Matplotlibdata~15 mins

Box plot with plt.boxplot in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Box plot with plt.boxplot
📖 Scenario: You are a data analyst working with a small dataset of daily temperatures recorded over a week. You want to visualize the spread and identify any outliers in the temperature data using a box plot.
🎯 Goal: Create a box plot using plt.boxplot to visualize the temperature data.
📋 What You'll Learn
Create a list variable named temperatures with the exact values: 22, 21, 23, 24, 30, 20, 19
Create a variable named fig and ax by calling plt.subplots()
Use ax.boxplot to create a box plot of the temperatures list
Set the title of the plot to exactly 'Daily Temperatures Box Plot'
Print the box plot figure object fig to confirm creation
💡 Why This Matters
🌍 Real World
Box plots are used in data science to quickly see the distribution, spread, and outliers of data like temperatures, sales, or test scores.
💼 Career
Data analysts and scientists use box plots to summarize data visually and communicate insights clearly to teams and stakeholders.
Progress0 / 4 steps
1
Create the temperature data list
Create a list called temperatures with these exact values: 22, 21, 23, 24, 30, 20, 19.
Matplotlib
Need a hint?

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

2
Set up the plot figure and axes
Import matplotlib.pyplot as plt. Then create variables fig and ax by calling plt.subplots().
Matplotlib
Need a hint?

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

Use fig, ax = plt.subplots() to create the figure and axes.

3
Create the box plot with plt.boxplot
Use ax.boxplot to create a box plot of the temperatures list. Then set the plot title to exactly 'Daily Temperatures Box Plot' using ax.set_title.
Matplotlib
Need a hint?

Call ax.boxplot(temperatures) to draw the box plot.

Use ax.set_title('Daily Temperatures Box Plot') to add the title.

4
Display the box plot figure
Print the figure object fig to confirm the box plot was created.
Matplotlib
Need a hint?

Use print(fig) to display the figure object.