Multi-plot grid in Seaborn
Last Updated :
23 Jul, 2025
Prerequisites: Matplotlib, Seaborn
In this article, we are going to see multi-dimensional plot data, It is a useful approach to draw multiple instances of the same plot on different subsets of your dataset. It allows a viewer to quickly extract a large amount of information about a complex dataset. In Seaborn, we will plot multiple graphs in a single window in two ways. First with the help of Facetgrid() function and other by implicit with the help of matplotlib.
FacetGrid: FacetGrid is a general way of plotting grids based on a function. It helps in visualizing distribution of one variable as well as the relationship between multiple variables. Its object uses the dataframe as Input and the names of the variables that shape the column, row, or color dimensions of the grid, the syntax is given below:
Syntax: seaborn.FacetGrid( data, \*\*kwargs)
- data: Tidy dataframe where each column is a variable and each row is an observation.
- \*\*kwargs: It uses many arguments as input such as, i.e. row, col, hue, palette etc.
Below is the implementation of above method:
Import all Python libraries needed
Python
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Example 1: Here, we are Initializing the grid like this sets up the matplotlib figure and axes, but doesn’t draw anything on them, we are using the Exercise dataset which is well known dataset available as an inbuilt dataset in seaborn.
The basic usage of the class is very similar to FacetGrid. First you initialize the grid, then you pass plotting function to a map method and it will be called on each subplot.
Python
# loading of a dataframe from seaborn
exercise = sns.load_dataset("exercise")
# Form a facetgrid using columns
sea = sns.FacetGrid(exercise, col = "time")
Output:

Example 2: This function will draw the figure and annotate the axes. To make a relational plot, First, you initialize the grid, then you pass the plotting function to a map method and it will be called on each subplot.
Python
# Form a facetgrid using columns with a hue
sea = sns.FacetGrid(exercise, col = "time", hue = "kind")
# map the above form facetgrid with some attributes
sea.map(sns.scatterplot, "pulse", "time", alpha = .8)
# adding legend
sea.add_legend()
Output:

Example 3: There are several options for controlling the look of the grid that can be passed to the class constructor.
Python
sea = sns.FacetGrid(exercise, row = "diet",
col = "time", margin_titles = True)
sea.map(sns.regplot, "id", "pulse", color = ".3",
fit_reg = False, x_jitter = .1)
Output:

Example 4: The size of the figure is set by providing the height of each facet, along with the aspect ratio:
Python
sea = sns.FacetGrid(exercise, col = "time",
height = 4, aspect =.5)
sea.map(sns.barplot, "diet", "pulse",
order = ["no fat", "low fat"])
Output:

Example 5: The default ordering of the facets is derived from the information in the DataFrame. If the variable used to define facets has a categorical type, then the order of the categories is used. Otherwise, the facets will be in the order of appearance of the category levels. It is possible, however, to specify an ordering of any facet dimension with the appropriate *_order parameter:
Python
exercise_kind = exercise.kind.value_counts().index
sea = sns.FacetGrid(exercise, row = "kind",
row_order = exercise_kind,
height = 1.7, aspect = 4)
sea.map(sns.kdeplot, "id")
Output:

Example 6: If you have many levels of one variable, you can plot it along the columns but “wrap” them so that they span multiple rows. When doing this, you cannot use a row variable.
Python
g = sns.PairGrid(exercise)
g.map_diag(sns.histplot)
g.map_offdiag(sns.scatterplot)
Output:

Example 7:
In this example, we will see that we can also plot multiplot grid with the help of pairplot() function. This shows the relationship for (n, 2) combination of variable in a DataFrame as a matrix of plots and the diagonal plots are the univariate plots.
Python
# importing packages
import seaborn
import matplotlib.pyplot as plt
# loading dataset using seaborn
df = seaborn.load_dataset('tips')
# pairplot with hue sex
seaborn.pairplot(df, hue ='size')
plt.show()
Output

Method 2: Implicit with the help of matplotlib.
In this we will learn how to create subplots using matplotlib and seaborn.
Import all Python libraries needed
Python
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Setting seaborn as default style even
# if use only matplotlib
sns.set()
Example 1: Here, we are Initializing the grid without arguments returns a Figure and a single Axes, which we can unpack using the syntax below.
Python
figure, axes = plt.subplots()
figure.suptitle('Geeksforgeeks - one axes with no data')
Output:

Example 2: In this example we create a plot with 1 row and 2 columns, still no data passed i.e. nrows and ncols. If given in this order, we don't need to type the arg names, just its values.
- figsize set the total dimension of our figure.
- sharex and sharey are used to share one or both axes between the charts.
Python
figure, axes = plt.subplots(1, 2, sharex=True, figsize=(10,5))
figure.suptitle('Geeksforgeeks')
axes[0].set_title('first chart with no data')
axes[1].set_title('second chart with no data')
Output:

Example 3: If you have many levels
Python
figure, axes = plt.subplots(3, 4, sharex=True, figsize=(16,8))
figure.suptitle('Geeksforgeeks - 3 x 4 axes with no data')
Output

Example 4: Here, we are Initializing matplotlib figure and axes, In this example, we are passing required data on them with the help of the Exercise dataset which is a well-known dataset available as an inbuilt dataset in seaborn. By using this method you can plot any number of the multi-plot grid and any style of the graph by implicit rows and columns with the help of matplotlib in seaborn. We are using sns.boxplot here, where we need to set the argument with the correspondent element from the axes variable.
Python
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, axes = plt.subplots(2, 3, figsize=(18, 10))
fig.suptitle('Geeksforgeeks - 2 x 3 axes Box plot with data')
iris = sns.load_dataset("iris")
sns.boxplot(ax=axes[0, 0], data=iris, x='species', y='petal_width')
sns.boxplot(ax=axes[0, 1], data=iris, x='species', y='petal_length')
sns.boxplot(ax=axes[0, 2], data=iris, x='species', y='sepal_width')
sns.boxplot(ax=axes[1, 0], data=iris, x='species', y='sepal_length')
sns.boxplot(ax=axes[1, 1], data=iris, x='species', y='petal_width')
sns.boxplot(ax=axes[1, 2], data=iris, x='species', y='petal_length')
Output:

Example 5: A gridspec() is for a grid of rows and columns with some specified width and height space. The plt.GridSpec object does not create a plot by itself but it is simply a convenient interface that is recognized by the subplot() command.
Python
import matplotlib.pyplot as plt
Grid_plot = plt.GridSpec(2, 3, wspace = 0.8,
hspace = 0.6)
plt.subplot(Grid_plot[0, 0])
plt.subplot(Grid_plot[0, 1:])
plt.subplot(Grid_plot[1, :2])
plt.subplot(Grid_plot[1, 2])
Output:

Example 6: Here we'll create a 3Ă—4 grid of subplot using subplots(), where all axes in the same row share their y-axis scale, and all axes in the same column share their x-axis scale.
Python
import matplotlib.pyplot as plt
figure, axes = plt.subplots(3, 4,
figsize = (15, 10))
figure.suptitle('Geeksforgeeks - 2 x 3 axes grid plot using subplots')
Output:

Similar Reads
Data Science Tutorial Data Science is a field that combines statistics, machine learning and data visualization to extract meaningful insights from vast amounts of raw data and make informed decisions, helping businesses and industries to optimize their operations and predict future trends.This Data Science tutorial offe
3 min read
Introduction to Machine Learning
What is Data Science?Data science is the study of data that helps us derive useful insight for business decision making. Data Science is all about using tools, techniques, and creativity to uncover insights hidden within data. It combines math, computer science, and domain expertise to tackle real-world challenges in a
8 min read
Top 25 Python Libraries for Data Science in 2025Data Science continues to evolve with new challenges and innovations. In 2025, the role of Python has only grown stronger as it powers data science workflows. It will remain the dominant programming language in the field of data science. Its extensive ecosystem of libraries makes data manipulation,
10 min read
Difference between Structured, Semi-structured and Unstructured dataBig Data includes huge volume, high velocity, and extensible variety of data. There are 3 types: Structured data, Semi-structured data, and Unstructured data. Structured data - Structured data is data whose elements are addressable for effective analysis. It has been organized into a formatted repos
2 min read
Types of Machine LearningMachine learning is the branch of Artificial Intelligence that focuses on developing models and algorithms that let computers learn from data and improve from previous experience without being explicitly programmed for every task.In simple words, ML teaches the systems to think and understand like h
13 min read
What's Data Science Pipeline?Data Science is a field that focuses on extracting knowledge from data sets that are huge in amount. It includes preparing data, doing analysis and presenting findings to make informed decisions in an organization. A pipeline in data science is a set of actions which changes the raw data from variou
3 min read
Applications of Data ScienceData Science is the deep study of a large quantity of data, which involves extracting some meaning from the raw, structured, and unstructured data. Extracting meaningful data from large amounts usesalgorithms processing of data and this processing can be done using statistical techniques and algorit
6 min read
Python for Machine Learning
Learn Data Science Tutorial With PythonData Science has become one of the fastest-growing fields in recent years, helping organizations to make informed decisions, solve problems and understand human behavior. As the volume of data grows so does the demand for skilled data scientists. The most common languages used for data science are P
3 min read
Pandas TutorialPandas is an open-source software library designed for data manipulation and analysis. It provides data structures like series and DataFrames to easily clean, transform and analyze large datasets and integrates with other Python libraries, such as NumPy and Matplotlib. It offers functions for data t
6 min read
NumPy Tutorial - Python LibraryNumPy (short for Numerical Python ) is one of the most fundamental libraries in Python for scientific computing. It provides support for large, multi-dimensional arrays and matrices along with a collection of mathematical functions to operate on arrays.At its core it introduces the ndarray (n-dimens
3 min read
Scikit Learn TutorialScikit-learn (also known as sklearn) is a widely-used open-source Python library for machine learning. It builds on other scientific libraries like NumPy, SciPy and Matplotlib to provide efficient tools for predictive data analysis and data mining.It offers a consistent and simple interface for a ra
3 min read
ML | Data Preprocessing in PythonData preprocessing is a important step in the data science transforming raw data into a clean structured format for analysis. It involves tasks like handling missing values, normalizing data and encoding variables. Mastering preprocessing in Python ensures reliable insights for accurate predictions
6 min read
EDA - Exploratory Data Analysis in PythonExploratory Data Analysis (EDA) is a important step in data analysis which focuses on understanding patterns, trends and relationships through statistical tools and visualizations. Python offers various libraries like pandas, numPy, matplotlib, seaborn and plotly which enables effective exploration
6 min read
Introduction to Statistics
Statistics For Data ScienceStatistics is like a toolkit we use to understand and make sense of information. It helps us collect, organize, analyze and interpret data to find patterns, trends and relationships in the world around us.From analyzing scientific experiments to making informed business decisions, statistics plays a
12 min read
Descriptive StatisticStatistics is the foundation of data science. Descriptive statistics are simple tools that help us understand and summarize data. They show the basic features of a dataset, like the average, highest and lowest values and how spread out the numbers are. It's the first step in making sense of informat
5 min read
What is Inferential Statistics?Inferential statistics is an important tool that allows us to make predictions and conclusions about a population based on sample data. Unlike descriptive statistics, which only summarize data, inferential statistics let us test hypotheses, make estimates, and measure the uncertainty about our predi
7 min read
Bayes' TheoremBayes' Theorem is a mathematical formula used to determine the conditional probability of an event based on prior knowledge and new evidence. It adjusts probabilities when new information comes in and helps make better decisions in uncertain situations.Bayes' Theorem helps us update probabilities ba
13 min read
Probability Data Distributions in Data ScienceUnderstanding how data behaves is one of the first steps in data science. Before we dive into building models or running analysis, we need to understand how the values in our dataset are spread out and thatâs where probability distributions come in.Let us start with a simple example: If you roll a f
8 min read
Parametric Methods in StatisticsParametric statistical methods are those that make assumptions regarding the distribution of the population. These methods presume that the data have a known distribution (e.g., normal, binomial, Poisson) and rely on parameters (e.g., mean and variance) to define the data.Key AssumptionsParametric t
6 min read
Non-Parametric TestsNon-parametric tests are applied in hypothesis testing when the data does not satisfy the assumptions necessary for parametric tests, such as normality or equal variances. These tests are especially helpful for analyzing ordinal data, small sample sizes, or data with outliers.Common Non-Parametric T
5 min read
Hypothesis TestingHypothesis testing compares two opposite ideas about a group of people or things and uses data from a small part of that group (a sample) to decide which idea is more likely true. We collect and study the sample data to check if the claim is correct.Hypothesis TestingFor example, if a company says i
9 min read
ANOVA for Data Science and Data AnalyticsANOVA is useful when we need to compare more than two groups and determine whether their means are significantly different. Suppose you're trying to understand which ingredients in a recipe affect its taste. Some ingredients, like spices might have a strong influence while others like a pinch of sal
9 min read
Bayesian Statistics & ProbabilityBayesian statistics sees unknown values as things that can change and updates what we believe about them whenever we get new information. It uses Bayesâ Theorem to combine what we already know with new data to get better estimates. In simple words, it means changing our initial guesses based on the
6 min read
Feature Engineering
Model Evaluation and Tuning
Data Science Practice