0
0
Matplotlibdata~15 mins

Basic scatter plot with plt.scatter in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic scatter plot with plt.scatter
📖 Scenario: You are a data analyst working with a small dataset of students' study hours and their exam scores. You want to visualize the relationship between study hours and exam scores using a scatter plot.
🎯 Goal: Create a scatter plot using plt.scatter to show how study hours relate to exam scores.
📋 What You'll Learn
Create two lists: study_hours and exam_scores with exact values.
Create a variable point_color to set the color of the scatter points.
Use plt.scatter with the lists and point_color to plot the points.
Display the scatter plot using plt.show().
💡 Why This Matters
🌍 Real World
Scatter plots help visualize relationships between two sets of numbers, like hours studied and exam scores, to find patterns.
💼 Career
Data analysts and scientists use scatter plots to explore data and communicate findings clearly.
Progress0 / 4 steps
1
Create the data lists
Create a list called study_hours with these exact values: [2, 3, 5, 7, 8]. Also create a list called exam_scores with these exact values: [50, 60, 70, 80, 90].
Matplotlib
Need a hint?

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

2
Set the color for scatter points
Create a variable called point_color and set it to the string 'blue' to use as the color for the scatter plot points.
Matplotlib
Need a hint?

Assign the string 'blue' to the variable point_color.

3
Create the scatter plot
Import matplotlib.pyplot as plt. Then use plt.scatter with study_hours, exam_scores, and the color set by point_color to create the scatter plot.
Matplotlib
Need a hint?

Use import matplotlib.pyplot as plt at the top. Then call plt.scatter() with the two lists and color=point_color.

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

Call plt.show() to open the window with the scatter plot.