Lecture

Relational Plots in Seaborn – Scatter and Line Plots

Relational plots allow you to explore how two variables interact or correlate.

In Seaborn, the two key functions for relational data are:

  • scatterplot() – Visualizes the relationship between two continuous variables using points.
  • lineplot() – Illustrates trends or patterns between variables using lines.

Both belong to Seaborn’s relational plotting family.

When to Use Scatter vs. Line

  • Scatter plot – Best for examining how one variable changes with another without assuming continuity (e.g., height vs. weight).
  • Line plot – Best for showing trends or progressions across an ordered variable, such as time or sequence.

Basic Scatter Plot

Simple Scatter Plot
import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset("tips") sns.scatterplot(data=tips, x="total_bill", y="tip") plt.title("Scatter Plot of Total Bill vs Tip") plt.show()

Basic Line Plot

Simple Line Plot
fmri = sns.load_dataset("fmri") sns.lineplot(data=fmri, x="timepoint", y="signal") plt.title("Line Plot of Signal over Time") plt.show()

ou can further enhance relational plots using parameters such as hue, style, and size — adding categories, visual patterns, or size variations to represent extra dimensions of data.

Quiz
0 / 1

Which Seaborn function is best suited for visualizing trends over an ordered sequence?

scatterplot()

pairplot()

lineplot()

barplot()

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help