Various Plot types in Seaborn
Categorical Data
- Data which takes on a limited and fixed number of values.
- Normally combined with numeric data
- Examples include:
- Geography (country, state, region)
- Gender
- Ethinicity
- Blood type
- 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.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.
df.isna().sum()- counts the number of NaN values in the DataFrame.
4. Data Visualization Part
Plots of each observation — stripplot
a) Creating a stripplot using Seaborn’s in-built stripplot() function
b) Customizing stripplot
Plots of each observation — swarmplot
Creating a swarmplot with Seaborn’s in-built swarmplot() function.
Plots of showing abstract representations — boxplot, violinplot and lvplot
a) Creating subplots for all the abstract representations plots
b) Customizing all the subplots by passing 3rd parameter and different palettes to all the functions
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”.
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.
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.
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.