Visualization with Multi-Plot Grids

In this lesson, we will discuss how to use Seaborn to create multi-plot grids.

Introduction to multi-plot grids #

Seaborn also has some multi-plot grid capabilities.

I don’t think I could explain it any better than the Seaborn documentation:

When exploring medium-dimensional data, a useful approach is to draw multiple instances of the same plot on different subsets of your dataset. This technique is sometimes called either “lattice” or “trellis” plotting, and it is related to the idea of “small multiples”. It allows a viewer to quickly extract a large amount of information about complex data. Matplotlib offers good support for making figures with multiple axes; seaborn builds on top of this to directly link the structure of the plot to the structure of your dataset.

Multi-plot grids in Python #

FacetGrid and map #

I think the easiest way to understand, is to use an example in Python from the flight’s dataset.

First, we will look at the FacetGrid() and map() combination in Seaborn.

The parameters we will use for FacetGrid are:

  • data which is the first parameter and specifies the dataframe to use.
  • row which is the column name from your dataframe you want to use as the rows of your grid.
  • col which is the column name from your dataframe you want to use as the columns of your grid.
  • margin_titles which if True, the titles for the row variable are drawn to the right of the last column.

The parameters we will use for map are:

  • func which is the first argument and is the plotting function you wish to use.
  • args is the second parameter and is the column name for the variable you wish to plot.
  • color which allows you to specify the plot color.

Let’s take a look:

Get hands-on with 1400+ tech skills courses.