Data Analysis and Visualization:
Data Visualization in
Python With Libraries
SSODL
Dr. Baljeet Kaur
Symbiosis International University
• What is Data Visualization?
• Data Visualization in Python
• Matplotlib and Seaborn
SSODL
• Line Charts
• Bar Graphs
• Histograms
• Scatter Plots
Photo by Nick Fewings on Unsplash
• Heat Maps
Data Visualization
• The process of finding trends and correlations in our data by
representing it pictorially is called Data Visualization.
• Data visualization is a field in data analysis that deals with visual
SSODL
representation of data. It graphically plots data and is an effective way
to communicate inferences from data.
• More effective in case of large datasets.
Data Visualization in Python
• Python offers several plotting libraries, with
different features for creating informative,
customized, and appealing plots to present data
in the most simple and effective way.
SSODL
Matplotlib and Seaborn: Matplotlib and
Seaborn are python libraries that are used for
data visualization.
They have inbuilt modules for plotting different
graphs. While Matplotlib is used to embed
graphs into applications, Seaborn is primarily
used for statistical graphs
Line chart
• A Line chart is a graph that represents information as a series of data
points connected by a straight line. In line charts, each data point or
marker is plotted and connected with a line or curve.
• Let's consider the apple yield (tons per hectare) in Kanto. Let's plot a
SSODL
line graph using this data and see how the yield of apples changes
over time. We start by importing Matplotlib and Seaborn.
Features Matplotlib Seaborn
Seaborn contains a number of
It is utilized for making basic
patterns and plots for data
graphs. Datasets are visualised with
visualization. It uses fascinating
Functionality the help of bargraphs, histograms,
themes. It helps in compiling whole
piecharts, scatter plots, lines and so
data into a single plot. It also
on.
provides distribution of data.
It uses comparatively complex and It uses comparatively simple syntax
SSODL
lengthy syntax. Example: Syntax for which is easier to learn and
Syntax bargraph- understand. Example: Syntax for
matplotlib.pyplot.bar(x_axis, bargraph- seaborn.barplot(x_axis,
y_axis). y_axis).
We can open and use multiple
figures simultaneously. However
Seaborn sets time for the creation
they are closed distinctly. Syntax to
of each figure. However, it may
Dealing Multiple Figures close one figure at a time:
lead to (OOM) out of memory
matplotlib.pyplot.close(). Syntax to
issues
close all the figures:
matplotlib.pyplot.close(“all”)
Features Matplotlib Seaborn
Matplotlib is well connected with
Numpy and Pandas and acts as a
Seaborn is more comfortable in
graphics package for data visualization
handling Pandas data frames. It uses
Visualization in python. Pyplot provides similar
basic sets of methods to provide
features and syntax as in MATLAB.
beautiful graphics in python.
Therefore, MATLAB users can easily
study it.
Matplotlib is a highly customized and Seaborn avoids overlapping of plots
Pliability
SSODL
robust with the help of its default themes
Matplotlib works efficiently with data Seaborn is much more functional and
frames and arrays.It treats figures and organized than Matplotlib and treats
axes as objects. It contains various the whole dataset as a single unit.
Data Frames and Arrays
stateful APIs for plotting. Therefore Seaborn is not so stateful and
plot() like methods can work without therefore, parameters are required
parameters. while calling methods like plot()
Seaborn is the extended version of
Matplotlib plots various graphs using Matplotlib which uses Matplotlib
Use Cases
Pandas and Numpy along with Numpy and Pandas for
plotting graphs