학습 자료

Relational Plots in Seaborn – Scatter and Line Plots

Relational plots help you understand how two variables relate to each other.
In Seaborn, the two main functions for this are:

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

Both functions are part of Seaborn’s relational plotting category.


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 over an ordered sequence (e.g., time series data).

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.show()

Basic Line Plot

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

Relational plots can be further customized with parameters like hue, style, and size to add categories, patterns, or variable-sized points.

You’ll explore these enhancements in the Jupyter Notebook on the right side of the screen.

Quiz
0 / 1

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

scatterplot()

pairplot()

lineplot()

barplot()

학습 자료

AI 튜터

디자인

업로드

수업 노트

즐겨찾기

도움말