Pair grid

Seaborn basics

1 min read

Published Oct 7 2025


24
0
0
0

ChartsGraphsMatplotlibNumPyPandasPythonSeabornVisualisation

seaborn.PairGrid() creates a matrix of subplots (like pairplot()) to show pairwise relationships between multiple variables.

It’s the lower-level, fully customisable version of sns.pairplot().
You can:

  • Control what kind of plot appears in each section (upper, lower, diagonal)
  • Add custom plots or transformations
  • Mix multiple plot types in one grid

Syntax:

sns.PairGrid(
    data,
    *,
    vars=None,
    x_vars=None,
    y_vars=None,
    hue=None,
    palette=None,
    hue_kws=None,
    corner=False,
    diag_sharey=True,
    height=2.5,
    aspect=1,
    despine=True,
    dropna=True,
)

Parameters:

  • data = DataFrame containing the data
  • vars = List of variables to include (both x and y)
  • x_vars, y_vars = Separate lists for asymmetric grids
  • hue = Variable for colour grouping
  • palette = Colour palette for hue
  • corner = If True, show only lower triangle
  • height = Height (inches) of each subplot
  • aspect = Aspect ratio of each subplot
  • diag_sharey = Share y-axis across diagonal plots
  • despine = Remove spines for cleaner look




Add different plots to diagonal and off-diagonal

import seaborn as sns
import matplotlib.pyplot as plt

iris = sns.load_dataset("iris")

g = sns.PairGrid(iris, hue="species", palette="Set2")
g.map_lower(sns.scatterplot)
g.map_diag(sns.kdeplot, fill=True)
g.map_upper(sns.kdeplot)
g.add_legend()
plt.show()

  • Lower triangle = scatterplots
  • Upper triangle = KDE contours
  • Diagonal = smoothed KDE of each variable
  • Adds legend automatically

seaborn pairgrid plot example

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact