Regression Plots

A regression plot combines a scatter plot with a fitted regression line, giving you both the raw relationship between two variables and a statistical summary of that relationship in one view.

Why Use a Regression Plot

  • Visually confirms whether a linear (or polynomial) fit is appropriate for the data
  • Highlights the direction and approximate strength of the relationship
  • Makes it easy to spot points that deviate strongly from the fitted trend

Plotting with Seaborn

import seaborn as sns
import matplotlib.pyplot as plt

sns.regplot(x="hours_studied", y="exam_score", data=df, color="#ff5421")
plt.title("Hours Studied vs Exam Score")
plt.show()

Confidence Interval Band

Seaborn's regplot() shades a confidence interval around the fitted line by default, giving a visual sense of the uncertainty in the estimate - a narrower band indicates a more confident fit.

Regression Plots vs Regression Models

A regression plot is a diagnostic and communication tool, not a substitute for fitting an actual regression model (as covered in Simple and Multiple Linear Regression). Use it before and after model building to sanity-check assumptions and results.

If the scatter of points curves rather than following a straight line, a linear regression plot can still be drawn - but it will fit poorly. Consider a polynomial or non-linear fit instead.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course