Relational plots in Seaborn - Part I

Last Updated : 26 Jun, 2026

Relational plots are used to visualise relationships between variables in a dataset. They help identify trends, patterns and correlations between data points. Seaborn provides several functions for creating relational plots, including relplot(), scatterplot() and lineplot().

Implementation

1. Import Required Libraries

Python
import seaborn as sns
import matplotlib.pyplot as plt

2. Load the Dataset

The built-in tips dataset is loaded.

Python
tips = sns.load_dataset("tips")
tips.head()

Output:

output
Dataset

3. Create a Basic Relational Plot

This creates a simple relational (scatter) plot.

  • Shows the relationship between total bill and tip.
  • Each point represents one observation.
  • Helps identify trends between the two variables.
Python
sns.set(style="ticks")

sns.relplot(
    x="total_bill",
    y="tip",
    data=tips
)

plt.show()

Output:

scatter-plot
Scatter Plot

4. Group Data Using Hue

The hue parameter separates data points using different colors.

  • Distinguishes between Lunch and Dinner customers.
  • Makes category wise comparisons easier.
Python
sns.relplot(
    x="total_bill",
    y="tip",
    hue="time",
    data=tips
)

plt.show()

Output

hue
Output

5. Create Faceted Relational Plots

This creates multiple plots based on categories.

  • row="sex" creates separate rows for males and females.
  • col="time" creates separate columns for lunch and dinner.
  • Allows comparison across multiple categories simultaneously.
Python
sns.relplot(
    x="total_bill",
    y="tip",
    hue="day",
    col="time",
    row="sex",
    data=tips
)

plt.show()

Output:

faceted-realational-plots
Output

6. Use Different Point Sizes

The size parameter changes the marker size according to the group size.

  • Larger points represent larger groups.
  • Adds an extra dimension to the visualization.
Python
sns.relplot(
    x="total_bill",
    y="tip",
    hue="day",
    size="size",
    data=tips
)

plt.show()

Output:

different-point-sizes
Output

7. Create a Line Relational Plot

This creates a line plot instead of a scatter plot.

  • Shows trends and patterns in the data.
  • Useful for analyzing changes between variables.
Python
sns.relplot(
    x="total_bill",
    y="tip",
    kind="line",
    data=tips
)

plt.show()

Output:

line-plot
Line Plot

Download fullcode from here

Comment