A pairplot plot a pairwise relationships in a dataset. The pairplot function creates a grid of Axes such that each variable in data will by shared in the y-axis across a single row and in the x-axis across a single column. That creates plots as shown below.

Related course: Matplotlib Examples and Video Course

pairplot

pairplot

The pairplot plot is shown in the image below. Its using the (famous) iris flower data set. The data set has 4 measurements: sepal width, sepal length, petal_length and petal_width. The data contains measurements of different flowers.

This dataset is often used in machine learning, because the measurements and classes (flowers) provide an excellent way to distinguish classes. The data is mapped in the grid below. Because there are 4 measurements, it creates a 4x4 plot.

1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/python3

import seaborn as sns

sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
g = sns.pairplot(iris)


import matplotlib.pyplot as plt
plt.show()

pairplot

If you prefer a smaller plot, use less variables. For instance, if you only want sepal_width and sepal_length, tha would create a 2x2 plot.

1
g = sns.pairplot(iris, vars=["sepal_width", "sepal_length"])

You can change the shape of the distribution.

1
g = sns.pairplot(iris, diag_kind="kde")

If you are new to matplotlib, then I highly recommend this course.