These 7 categorical plots forced me to love Seaborn Library.

Amsavalli Mylasalam
Variablz Academy
Published in
3 min readOct 19, 2022
Love with Seaborn: Credits (Aatomz)

Plotting categorical variables is always a challenging task for data scientists. However, there are dozens of libraries that do the magic of plotting. I am gonna explain the categorical plots which forced me to love Seaborn Library.

Click 👉🏻 here to download the Early stage diabetes risk prediction dataset from Kaggle to reproduce this code.

Import Libraries and Data

Load data file into Pandas Data Frame.

1. Paired Bar Plot

Paired Bar Plot is the vertical bar that separates two discrete, intimately related set of data.

2. Count Plot:

Countplot () is used to express the counts of observations in each categorical bin using bars.

Let's create a count plot for Gender and partial paresis as a hue parameter. And plot horizontally to make more space for category labels.

3. Stripplot:

A StripPlot is a scatterplot for separate categories. It’s suitable for multivariate analysis.

The issue of point overlapping in a strip plot can be partially fixed by setting the alpha parameter that regulates point transparency.

Let's create a strip plot for the Visual Blurring and Age feature, a vast strip plot for gender.

4. SwarmPlot:

SwarmPlot is the categorical scatterplot with points adjusted to be non-overlapping.

In Swarmplot, we can show all observations and some representation of the underlying distribution.

Let's consider this example:

5. Box Plot:

A box plot or whisker plot is the primary statistical tool for visualizing data, and it's a distribution plot concerning categories.

Consider the below example for a box plot.

6. ViolinPlot:

ViolinPlot is the categorical distribution plot, a combination of the ba ox plot and kernel density estimate.

The below example shows the distribution of Delayed Healing quantitative data across several levels of Age and Gender categorical variables such that those distributions can be compared.

7. Displot:

A display figures out the distribution of observations. We can use a displot display or distribution plot ta in histogram form.

This example shows how Age is distributed along with the gender category feature.

While comparing to the Matplotlib library, the Seaborn library allows us to analyze our data rapidly and comfortably in simple steps. That’s why I mostly end up with the Seaborn library while plotting Categorical variables.

What is your favorite for Categorical variable plots? Let me know in the comments.

For more insights from data visualization, follow me on LinkedIn.

https://www.linkedin.com/in/amsavalli-datascientist/

Thanks & Regards

Amsavalli Mylasalam

--

--