Last Updated : 23 Jul, 2025
Prerequisite: seaborn
A grouped boxplot is a boxplot where categories are organized in groups and subgroups. Whenever we want to visualize data in the group and subgroup format the Seaborn Catplot() plays a major role. The following example visualizes the distribution of 7 groups (called A to G) and 2 subgroups (called low and high) in grouped boxplot format. To generate boxplot using Seaborn generally uses the boxplot() method but here we use a much newer method Catplot(). The Catplot() accesses several axes-level functions that show the relationship between a numerical and one or more categorical variables using one of several visual representations.
Grouped BoxplotIn this article, we will learn how to generates Grouped Boxplot using Seaborn Catplot. Please follow the steps mentioned below -
Syntax:
catplot(x, y, hue, data, height ,kind)
Example 1: Horizontal Boxplot
Python3
import pandas as pd
import seaborn as sns
df = pd.read_csv("titanic_train.csv")
df.dropna()
sns.catplot(x='Sex', y='Fare', hue='Survived',
data=df, height=9, kind="box")
Output :
Example 2: Vertical Boxplot
This example depicts how we can plot the same data horizontally. This can be achieved simply by swapping values provided to x and y.
Python3
import pandas as pd
import seaborn as sns
df = pd.read_csv("titanic_train.csv")
df.dropna()
sns.catplot(y='Sex', x='Fare', hue='Survived',
data=df, height=9, kind="box")
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4