Pair Plots
Why pair plots?
Pair plots are a fast way to inspect:
- Pairwise relationships between variables
- Distributions on the diagonal
- Group separation using
huehue
They are great early in EDA.
flowchart TD A["n numeric columns"] --> B["Build an n x n grid"] B --> C["Off-diagonal cells:
scatter of column i vs j"] B --> D["Diagonal cells:
histogram or KDE of column i"]
Basic pairplot
pairplot
import seaborn as sns
penguins = sns.load_dataset("penguins").dropna()
sns.pairplot(penguins[[
"bill_length_mm",
"bill_depth_mm",
"flipper_length_mm",
"body_mass_g",
]])pairplot
import seaborn as sns
penguins = sns.load_dataset("penguins").dropna()
sns.pairplot(penguins[[
"bill_length_mm",
"bill_depth_mm",
"flipper_length_mm",
"body_mass_g",
]])Pairplot with hue
pairplot with hue
import seaborn as sns
penguins = sns.load_dataset("penguins").dropna()
sns.pairplot(
penguins,
vars=["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"],
hue="species",
)pairplot with hue
import seaborn as sns
penguins = sns.load_dataset("penguins").dropna()
sns.pairplot(
penguins,
vars=["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"],
hue="species",
)Tips
- Pair plots can be slow for large datasets. Sample rows if needed.
- Use
huehueto check if groups separate naturally.
Next
Continue to Facet Grids to split any plot type into small multiples by category.
🧪 Try It Yourself
Exercise 1 – A Basic Pair Plot
Exercise 2 – Color by Species
Exercise 3 – Use KDE on the Diagonal
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
