Various Plot types in Seaborn

Ravjot Singh
Analytics Vidhya
Published in
4 min readMay 13, 2020

Categorical Data

  • Data which takes on a limited and fixed number of values.
  • Normally combined with numeric data
  • Examples include:
  1. Geography (country, state, region)
  2. Gender
  3. Ethinicity
  4. Blood type
  5. Eye color

Plot types

  • show each observations includes stripplot and swarmplot.
  • show abstract representations includes boxplot, violenplot and lvplot (also known as boxenplot).
  • show statistical estimates includes barplot, countplot and pointplot.

Let’s start visualizing using Seaborn

1. Importing the required libraries

2. Loading the dataset

Importing the csv data using pd.read_csv() function of Pandas library.

3. Exploratory data analysis (EDA)

Knowing the basic information about the data.

df.head()- gives the first 5 rows of the dataset as the output.

df.head() function of Pandas library

df.shape- as the name suggests, this function gives the shape of the data in the output.

df.info()- this function prints information about theDataFrame including the index dtype and column dtypes, non-null values and memory usage.

df.describe()- this function is used to view some basic statistical details like percentile, mean, std etc. of a data frame or a series of numeric values.

Statistical Analysis of the data

df.isna().sum()- counts the number of NaN values in the DataFrame.

Number of missing values in each column of dataset

4. Data Visualization Part

Plots of each observation — stripplot

a) Creating a stripplot using Seaborn’s in-built stripplot() function

Stripplot

b) Customizing stripplot

Customized stripplot

Plots of each observation — swarmplot

Creating a swarmplot with Seaborn’s in-built swarmplot() function.

Swarmplot

Plots of showing abstract representations — boxplot, violinplot and lvplot

a) Creating subplots for all the abstract representations plots

Boxplot, Violinplot and lvplot

b) Customizing all the subplots by passing 3rd parameter and different palettes to all the functions

Code
Output

Plots of statistical estimates — barplot

Creating a simple barplot using catplot() function of Seaborn by passing “kind” parameter equals to “bar” and passing data, x and y inputs and 3rd parameter equals to “hue”.

Horizontal barplot

Plots of statistical estimates — pointplot

Creating a pointplot with catplot() function of Seaborn library. Passing “kind” parameter equals to “point” creates a pointplot. Also, passing data, x and y inputs. By passing “col” parameter in the function creates subplots in columns.

Pointplot

Plots of statistical estimates — countplot

Creating a countplot with catplot() function of Seaborn library. Countplot can be formed by passing “kind” parameter equals to “count”. Passing all the other parameters like data and x input will create our pointplot. We can also customize our countplot by passing another parameter to “hue” in the function.

Countplot

This brings us to the end of this article. I hope you have understood all the visualizations clearly. Make sure you practice as much as possible.

You can download the dataset from here.

If you wish to check out more resources related to Data Science and Machine Learning you can refer to my Github account.

Do look out for other Jupyter notebooks in the series which will explain the various other aspects of Data Visualizations with Seaborn in Python.

You can also check my Data Science Portfolio on Github account.

Hope you like the post.

--

--

Ravjot Singh
Analytics Vidhya

A Tech enthusiast || Dedicated and hardworking with a passion for Data Science || Codes in Python & R.