Open In App

Types Of Seaborn Plots

Last Updated : 15 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Seaborn is a Python data visualization library based on Matplotlib that provides a high-level interface for drawing attractive and informative statistical graphics. It is built on top of matplotlib and integrates with pandas data structures making it an ideal choice for visualizing data from data frames and arrays.

Types Of Seaborn Plots

Below are the plots those we discuss in this article.

  • Relational Plots in Seaborn
  • Categorical Plots in Seaborn
  • Distribution Plots in Seaborn
  • Matrix Plots in Seaborn
  • Pair Grid in Seaborn

Relational Plots in Seaborn

Scatter Plot , Line Plot and Relational Plot are contained in the category of Relational Plots in Seaborn.

1. Scatter Plot

A scatter plot is a type of graph that uses Cartesian coordinates to display values for two variables for a set of data. Points on the plot indicate the values of the variables, allowing for visualization of any correlation or pattern.

We create a scatter plot using the "total_bill" column for the x-axis and the "tip" column for the y-axis from the "tips" dataset using the sns.scatterplot(data=tips, x="total_bill", y="tip") function

Python
import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.scatterplot(data=tips, x="total_bill", y="tip")

plt.show()

Output:

1
Scatter Plot

2. Line plot

A line plot is a type of graph that displays data points connected by straight lines, showing trends over a continuous interval or time period. It is useful for visualizing changes and trends in data over time.

We can create a line plot using the "size" column (number of people at the table) for the x-axis and the "tip" column for the y-axis from the "tips" dataset using sns.lineplot(data=tips, x="size", y="tip").This visualizes the relationship between the size of the party and the tip amount.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.lineplot(data=tips, x="size", y="tip")

plt.show()

Output:

2
Line Plot

3. Relational Plot (relplot):

A relational plot (relplot) is a versatile function in seaborn for creating scatter and line plots, with additional capabilities for faceting data into multiple subplots. It simplifies the creation of complex visualizations by handling various plot types and layouts automatically.

A relational plot using Seaborn to visualize some data. This code creates a relational plot that uses total_bill and tip from the tips dataset, with points colored by the smoker variable.

Python
import seaborn as sns
import matplotlib.pyplot as plt
sns.load_dataset("tips")

sns.relplot(data=tips, x="total_bill", y="tip", hue="smoker")

plt.show()

Output:

3
Relational Plot

Categorical Plots in Seaborn

Bar Plot ,Count Plot, Box Plot , Violin Plot , Strip Plot , Swarm Plot are some of the categorical plots in Seaborn.

1. Bar Plot (barplot):

A bar plot (barplot) displays categorical data with rectangular bars where the length of each bar represents the value of the corresponding category. It is useful for comparing quantities across different categories. Let's show the average total_bill for each day through bar plot.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.barplot(data=tips, x="day", y="total_bill")

plt.show()


Output:

4
Bar plot

2. Count Plot (countplot):

A count plot (countplot) is a bar plot that shows the frequency of occurrences for each category in a categorical variable. It visualizes the count of each unique value in the data. The below code generates a count plot showing the number of occurrences for each day in the tips dataset.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.countplot(data=tips, x="day")

plt.show()


Output:

5
Count Plot

3. Box Plot (boxplot):

A box plot displays the distribution of a dataset through its quartiles, highlighting the median, interquartile range and potential outliers. It provides a visual summary of the data's central tendency, dispersion, and skewness.

This code creates a box plot using the tips dataset, displaying the distribution of total_bill for each day.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.boxplot(data=tips, x="day", y="total_bill")

plt.show()


Output:

6
Box Plot

4. Violin Plot (violinplot):

A violin plot (violinplot) combines a box plot with a kernel density plot, showing the distribution, probability density, and central tendencies of the data. It provides a detailed view of the data's distribution, highlighting variations and multimodalities.

Th below code creates a violin plot showing the distribution of total_bill for each day in the tips dataset.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.violinplot(data=tips, x="day", y="total_bill")

plt.show()


Output:

7
Violin Plot

5. Strip Plot (stripplot):

A strip plot (stripplot) displays individual data points for one or more categorical variables, often overlaid on a box or violin plot. It shows the distribution and concentration of data points, highlighting any potential outliers. Below code generates a strip plot showing all total_bill values for each day in the tips dataset as individual points.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.stripplot(data=tips, x="day", y="total_bill")

plt.show()

Output:

8
Strip Plot

6. Swarm Plot

A swarm plot displays individual data points for one or more categorical variables, similar to a strip plot, but adjusts points to avoid overlap. It provides a clear view of the distribution and density of the data. This creates a swarm plot showing the distribution of total_bill for each day with non-overlapping points.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.swarmplot(data=tips, x="day", y="total_bill")

plt.show()

Output

9
Swarm Plot

Distribution Plots in Seaborn

1. Histogram (histplot):

A histogram (histplot) displays the distribution of a continuous variable by dividing data into bins and plotting the frequency of data points in each bin. It provides insights into the data's central tendency, dispersion, and shape. Let's generate a histogram showing the distribution of total_bill in the tips dataset.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.histplot(data=tips, x="total_bill")

plt.show()

Output

10
Histogram Plot

2. Kernel Density Estimate Plot (kdeplot):

A kernel density estimate plot (kdeplot) visualizes the probability density function of a continuous variable by smoothing the histogram with a kernel function. It provides a smooth representation of the data's distribution, allowing for better understanding of its shape and characteristics.KDE plot which is a smoothed version of the histogram showing the distribution of total_bill.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.kdeplot(data=tips, x="total_bill")

plt.show()

Output

11
Kernel Density Plot

3. Distribution Plot (displot):

A distribution plot (displot) is a versatile seaborn function that allows for visualization of univariate distributions. It can combine histograms, kernel density estimates, and rug plots to provide insights into the distribution of a single variable.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.displot(data=tips, x="total_bill", kind="kde")

plt.show()

Output

12
Distribution PLot

4. Empirical Cumulative Distribution Function Plot (ecdfplot):

An empirical cumulative distribution function plot (ecdfplot) displays the cumulative distribution of a continuous variable based on the observed data points. It shows how the data is spread across different percentiles and can be useful for comparing distributions or assessing goodness-of-fit.

This code creates an Empirical Cumulative Distribution Function (ECDF) plot showing the proportion of data points less than or equal to each total_bill value.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.ecdfplot(data=tips, x="total_bill")

plt.show()

Output

13
ecdf Plot

5. Rug Plot (rugplot):

A rug plot (rugplot) is a simple plot that displays individual data points along a single axis, usually the x-axis as small lines or ticks. It provides a visual representation of the data distribution and density, often used in combination with other types of plots like histograms or KDE plots. Let's generates a rug plot which show individual total_bill values as small vertical lines along the x-axis.

Python
import seaborn as sns
import matplotlib.pyplot as plt

sns.rugplot(data=tips, x="total_bill")

plt.show()

Output

14
Rug Plot

Matrix Plots in Seaborn

1. Heatmap (heatmap):

A heatmap (heatmap) is a graphical representation of data where values in a matrix are represented as colors. It's often used to visualize the magnitude of values in a matrix, allowing patterns and correlations to be easily identified. Below code creates a heatmap using the flights dataset and show the number of passengers each month over the years.

Python
import seaborn as sns
import matplotlib.pyplot as plt

flights = sns.load_dataset("flights")
flights_pivot = flights.pivot(index="month", columns="year", values="passengers")

sns.heatmap(flights_pivot, annot=True, fmt="d", cmap="YlGnBu")

plt.show()

Output

15
Heatmap

2. Cluster Map (clustermap):

A cluster map (clustermap) is a heatmap that organizes rows and columns of a dataset based on their similarity, often using hierarchical clustering. It's useful for identifying patterns and relationships in complex datasets by grouping similar rows and columns together. Let's see how to generate cluster map which clusters both rows and columns based on similarity, using the flights dataset.

Python
import seaborn as sns
import matplotlib.pyplot as plt

flights = sns.load_dataset("flights")
flights_pivot = flights.pivot(index="month", columns="year", values="passengers")

sns.clustermap(flights_pivot, cmap="viridis", standard_scale=1)

plt.show()

Output

8
Cluster Map

Pair Grid (PairGrid) in Seaborn

1. Pair Plot (pairplot):

A pair plot (pairplot) creates a grid of scatterplots and histograms for each pair of variables in a dataset, allowing for visual exploration of relationships and distributions between variables. It's particularly useful for identifying patterns and correlations in multivariate data.

Python
import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.pairplot(tips, hue="smoker", palette="coolwarm")

plt.show()

Output:

17

The above plot showing pairwise relationships between all numerical variables in the tips dataset.


Next Article

Similar Reads