Scatter plots with regression (regplot)
📖 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. Additionally, you want to add a regression line to see the trend clearly.
🎯 Goal: Create a scatter plot with a regression line using the seaborn library to visualize the relationship between study hours and exam scores.
📋 What You'll Learn
Create a dictionary called
data with keys 'Hours' and 'Scores' and the exact values specified.Create a pandas DataFrame called
df from the data dictionary.Create a variable called
plot_color and set it to the string 'blue'.Use
seaborn.regplot with df['Hours'] as x, df['Scores'] as y, and color=plot_color to create the scatter plot with regression line.Use
plt.show() to display the plot.💡 Why This Matters
🌍 Real World
Scatter plots with regression lines help analysts understand relationships between two variables, such as study hours and exam scores, to make data-driven decisions.
💼 Career
Data analysts and scientists often use scatter plots with regression lines to visualize trends and correlations in data, which is essential for reporting and predictive modeling.
Progress0 / 4 steps