0
0
Matplotlibdata~30 mins

Why scatter plots show relationships in Matplotlib - See It in Action

Choose your learning style9 modes available
Why scatter plots show relationships
📖 Scenario: Imagine you are a teacher who wants to understand if students' study hours affect their test scores. You have collected data on how many hours each student studied and their scores. You want to see if there is a pattern or relationship between these two things.
🎯 Goal: You will create a scatter plot to visually show the relationship between study hours and test scores. This will help you see if more study hours generally mean higher scores.
📋 What You'll Learn
Create two lists: study_hours and test_scores with exact values
Create a variable title with the exact string for the plot title
Use matplotlib.pyplot.scatter to plot the points with correct variables
Use plt.title to set the plot title
Use plt.xlabel and plt.ylabel to label axes
Use plt.show() to display the plot
💡 Why This Matters
🌍 Real World
Scatter plots help people see if two things are connected, like hours studied and test results, or temperature and ice cream sales.
💼 Career
Data scientists and analysts use scatter plots to quickly understand relationships in data before doing deeper analysis.
Progress0 / 4 steps
1
Create the data lists
Create a list called study_hours with these exact values: [1, 2, 3, 4, 5, 6, 7, 8]. Then create a list called test_scores with these exact values: [50, 55, 65, 70, 75, 80, 85, 90].
Matplotlib
Need a hint?

Use square brackets to create lists with the exact numbers given.

2
Create the plot title variable
Create a variable called title and set it to the string 'Study Hours vs Test Scores'.
Matplotlib
Need a hint?

Use single or double quotes to create the string exactly as shown.

3
Create the scatter plot
Import matplotlib.pyplot as plt. Then use plt.scatter with study_hours and test_scores to create the scatter plot. Use plt.title(title) to set the plot title. Use plt.xlabel('Study Hours') and plt.ylabel('Test Scores') to label the axes.
Matplotlib
Need a hint?

Remember to import matplotlib.pyplot as plt before plotting.

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

Use plt.show() to open the plot window and see the scatter plot.