Unit 5 Seaborn Visualization
Unit 5 Seaborn Visualization
Unit 5
Data Visualization
Using Seaborn
Data Visualization Using Seaborn
Disclaimer
The content is curated from online/offline resources and used for educational purpose only
Data Visualization Using Seaborn
Click here
Reference link
Data Visualization Using Seaborn
Learning Objectives
• Why should you use Seaborn versus matplotlib?
• Introduction to Seaborn
• Seaborn Vs Matplotlib
• Seaborn Installation
• Data Visualization using Seaborn
• Visualizing Statistical Relationship
• Visualizing Distribution of Data
Data Visualization Using Seaborn
What is Seaborn?
• Seaborn is a Python library used to generate statistical
graphics.
• It is built on top of matplotlib and closely integrates with
pandas data structures.
• Seaborn assists you in discovering and understanding
your data.
Data Visualization Using Seaborn
V/S
• In Seaborn, there are numerous patterns and • Matplotlib generates simple graphs such as bar
graphs for data visualisation. It uses interesting graphs, histograms, pie charts, scatter plots, lines,
themes and aids in the integration of all data into a and other data visualisations.
single plot. • It employs relatively complicated and extensive
• It has relatively simple syntax, making it simpler to syntax.
learn and comprehend.
• Matplotlib is a Python graphics package for data
• Seaborn is more comfortable with Pandas data
frames. It utilizes simple sets of techniques to visualization and integrates nicely with Numpy and
produce lovely images in Python. Pandas.
Data Visualization Using Seaborn
Installing Seaborn
To install the latest release of seaborn, you can use pip:
You can also use conda to install the latest version of seaborn:
1. Scatterplot
2. Lineplot
3. Regplot
4. Heatmap
5. Boxplot
6. Violinplot
Data Visualization Using Seaborn
Scatter Plot
• The scatter plot is a standard statistical visualisation tool.
The joint distribution of two variables is represented as a
cloud of points, with each point representing a dataset
observation.
Line Plot
The line plot is the most commonly used plot for
drawing a relationship between x and y, with the option
of several semantic groupings.
Reg Plot
Plot data and a linear regression model fit.
Parameters:
x, y: Input data variables; must be numeric. Can pass
data directly or reference columns in data.
Data Visualization Using Seaborn
Heat Map
A heat map is a two-dimensional representation of data
in which values are represented by colors.
Heatmap helps to correlate the different features in
order to take the decision.
# plotting heatmap
sns.heatmap(tips.corr())
Syntax : sns.lineplot(x=None, y=None)
Parameters:
x, y: Input data variables; must be numeric. Can pass
data directly or reference columns in data.
Data Visualization Using Seaborn
Box Plot
A box plot (or box-and-whisker plot) is a visual
representation of numerical data groups portrayed through
their quartiles versus continuous/categorical data.
Syntax:
seaborn.boxplot(x=None, y=None, hue=None,
data=None)
Parameters:
•x, y, hue: Inputs for plotting long-form data.
•data: Dataset for plotting. If x and y are absent, this is
interpreted as wide-form.
sns.boxplot( data['Age'] )
Data Visualization Using Seaborn
Violin Plot
• A violin plot functions similarly to a box plot. It depicts the
distribution of quantitative data across multiple levels of
one (or more) categorical variable, allowing those
distributions to be compared.
• sns.violinplot(x="day", y="total_bill",
data=t,palette='rainbow')
Data Visualization Using Seaborn
Swarm
striplot
plot
Violin Count
plot plot
Data Visualization Using Seaborn
Count Plot
• This is similar to barplot except that the estimator explicitly counts the number of occurrences. As a
result, we only pass the x value. The command for making a countplot is:
• sns.countplot(x='sex',data=t)
Data Visualization Using Seaborn
histplotplot
displot(Distributions) kdeplot
ecdfplot
Data Visualization Using Seaborn
1. Histograms
• One of the most popular methods for visualising a distribution is the histogram. This method is used by
default in the histplot()-based function displot(). A histogram is a bar plot in which the axis representing
the data variable is divided into discrete bins, and the height of the corresponding bar represents the
number of observations falling within each bin:
ds = seaborn.load_dataset(“ds")
seaborn.displot(ds, x="flipper_length_mm")
* ds is a dataset
Data Visualization Using Seaborn
seaborn.displot(ds, x="flipper_length_mm",
kind="kde")
Data Visualization Using Seaborn
Summary
Seaborn Advantages over Matplotlib: Simplified syntax and high-level interface for
creating aesthetically pleasing visualizations.
Quiz
1. What is a key advantage of using Seaborn over Matplotlib?
Answer: c) Seaborn simplifies syntax for complex plots and attractive statistical graphics.
Data Visualization Using Seaborn
Quiz
2. What this trend line indicate?
Quiz
3. What this plot indicate?
Quiz
4. Which Seaborn function is specifically used to visualize statistical relationships involving linear
regression?
a) Line Plot
b) Scatter Plot
c) Heatmap
d) All of the above
Quiz
5. Which type of visualization does Seaborn's distplot function primarily help in creating?
a) 3D scatter plots
b) Bar charts
c) Histograms and kernel density plots
d) Heatmaps
References
• https://seaborn.pydata.org/tutorial/relational.html
• https://www.analyticsvidhya.com/blog/2019/09/comprehensive-data-visualization-guide-seaborn-python/
• https://datahack.analyticsvidhya.com/contest/enigma-codefest-machine-learning-1/#ProblemStatement
• https://datahack.analyticsvidhya.com/contest/wns-analytics-hackathon-2018-1/#ProblemStatement
• https://towardsdatascience.com/data-visualization-using-seaborn-fc24db95a850
• https://www.freepik.com/
Data Visualization Using Seaborn
Thank you...!