Nothing Special   »   [go: up one dir, main page]

Data Visualization

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

DATA VISUALIZATION

DATA VISUALIZATION IS THE GRAPHICAL REPRESENTATION OF INFORMATION AND DATA. BY


USING VISUAL ELEMENTS LIKE CHARTS, GRAPHS, AND MAPS.
DATA VISUALIZATION
APPLICATIONS:
THE MAIN GOAL OF DATA VISUALIZATION IS TO MAKE IT EASIER TO IDENTIFY PATTERNS,
TRENDS AND OUTLIERS IN
1. Analyzing
LARGE the Data in a Better Way
DATA SETS
2. Faster Decision Making
3. Making Sense of Complicated Data

Fields:
Sales and marketing.
Politics.
Healthcare
Scientists
Finance

Examples:
sales analysis, market research analysis, customer analysis, defect analysis,
cost analysis, and Weather forecasting
DATA VISUALIZATION
data visualization libraries in Python:
Matplotlib
Matplotlib is a Python plotting library that allows you to construct
static, dynamic, and interactive visualizations
Matplotlib is a python library which provides many interfaces and
function to present data in 2D graphics.
Matplotlib library offers many different collections of sub modules
Pyplot is one such sub module.
Pyplot is a collection of methods within Matplotlib library which
allows user to construct 2D plots easily.
Other libraries
Seaborn , Ggplot, Bokeh ,pygal etc
DATA VISUALIZATION

To use Pyplot for data visualization, we have


to first import it in our python environment.
import matplotlib.pyplot
or
import matplotlib.pyplot as plt
DATA VISUALIZATION
Line charts are used to represent the relation between two data X and Y on a different axis .
A line chart is a type of chart which displays information as a series of data points connected by
straight line .
To create a line chart plot() function is used .
DATA VISUALIZATION
Create multiple line chart on a single plot : Multiple charts can be made using plot()
DATA VISUALIZATION
Various parameters of the plot() function :
1. Marker – different types of marker
2. Markersize e or ms
DATA VISUALIZATION
Various parameters of the plot() function :
3. Markerfacecolor or mfc - ’b’,’r’,’g’ etc
4. Markeredgecolor or mec - ’b’,’r’,’g’
DATA VISUALIZATION
Note : Marker type and marker color can be combined :
For Ex- ‘r+’ gives you line color and marker color red
and marker type +
DATA VISUALIZATION
Various parameters of the plot() function :
1. Color –’r’,’g’,’b’
2. Linestyle or ls
3. Linewidth : specify the width in points
DATA VISUALIZATION
The legend is a side section of the chart that gives a small text description of each series. You can specify the text
associated with each series in this legend, and specify where on the chart it should appear.
Matplotlib.pyplot.legend() function is used to create the
legend

To specify the position of the legend on the chart Loc parameter can be change
DATA VISUALIZATION
Matplotlib.pyplot.title() function can be used to display the title of the chart
Matplotlib.pyplot.savefig() function can be used to save the chart in jpeg or pdf format after plotting data
DATA VISUALIZATION
matplotlib.pyplot.xticks() and yticks() Function: by default pylpot will automatically decide which
data points will have ticks on the x axis or y axis but you can also decide which data points will
have the tick marks on X and Y axis.
DATA VISUALIZATION
matplotlib.pyplot.xlim() and ylim() Function: using this function you can specify the ranges for X
and Y
Note axisthe data values mapping on xlimits and ylimits will get plotted . If no data value maps to the
: only
xlimits and ylimits nothing will print
DATA VISUALIZATION
A bar chart or bar graph is a chart or graph that presents categorical data with rectangular bars with
heights or lengths proportional to the values that they represent
Python provides the bar() function to create bar chart
DATA VISUALIZATION
Multiple bar charts :
DATA VISUALIZATION
Customizing bar charts : Change color, width of charts
All bars with same width
DATA VISUALIZATION
Customizing bar charts : All bars with different width : A list of width can be
passed
DATA VISUALIZATION
Customizing bar charts : Change the color of bar

Change the color of each bar pass a list of colors


DATA VISUALIZATION
Multiple bar separately
DATA VISUALIZATION
Multiple bar chart : Stacked Bar Chart
DATA VISUALIZATION
Horizontal bar chart: to create horizontal bar chart barh() function can be used
DATA VISUALIZATION
Histogram:
1. Histogram was introduced by karl Pearson
2. A histogram is a graphical representation that organizes a group of data points into user-specified ranges.
3. A histogram is a bar graph-like representation of data that buckets a range of outcomes into
columns along the x-axis.
4. The y-axis represents the number count or percentage of occurrences in the data for each column and can
be used to visualize data distributions.
DATA VISUALIZATION
hist() function is used to create histogram
Default value of bin is 10
DATA VISUALIZATION
Bin=[1,2,3,4]
Then it has 3 bins
First bin is [1-2] excluding 2
Second bin is [2-3] excluding 3
Third bin is [3-4 ] including 4
Hist( ) Function Syntax :
<matplotlib.pyplot>.hist(x, bins = None, cumulative = Flase, histtype = 'bar', align = 'mid', orientation= 'vertical’)

Different parameters can be changed to customize the Histogram


X: Array or sequence of arrays to be plotted on Histogram

bins: an integer or sequence, used to divide the range in the histogram

cumulative: True or False, Default is False

histtype: {'bar', 'barstacked', 'step', 'stepfilled'}, Default 'bar’


align: {'left', 'mid', 'right'}, default is 'mid’

orientation: {'horizontal', 'vertical'}, Default 'horizontal'


DATA VISUALIZATION
Cumulative =True/False by default it is
False
DATA VISUALIZATION
Histtype = {'bar', 'barstacked', 'step', 'stepfilled'}, Default 'bar’
DATA VISUALIZATION
orientation: {'horizontal', 'vertical'}, Default ‘Vertical’

You might also like