You are on page 1of 27

DATA VISUALIZATION

USING
PYPLOT

SUBMITTED BY:AKSHIT PATEL


INTRODUCTION
 Data visualization
basically refers to the
graphical or visual
representation of
information & data
using visual elements
like
charts,graphs,maps
etc.
DATA VISUALIZATION IN
PYTHON
 Data visualization in python can be done via many packages one
example of a package is MATPLOTLIB.

 A package is a structured collection of modules that has


the same purpose.

 In python we can use two exclusive libraries for


visualization commonly known as MATPLOTLIB &
MATPLOTLIB
Matplotlib is a python 2D plotting
library which produces
publication quality figures.
PYPLOT
Pyplot is a module of matplotlib library of python.

Pyplot contains collection of methods which allows a


user to create 2D plots and graphs easily and
interactively.

The pyplot interface is generally preferred for non-


interactive plotting (i.e scripting).
NUMPY
Another library which helps in the process of plotting graphs using pyplt
is numpy.
Numpy is used for:

(a) Mathematical and logical operation on arrays.


(b) Fourier transforms & routines for shape manipulation.
(c) Operation related to linear algebra.
To install numpy type the following command at the command prompt.

>>>C:\pip install numpy (for windows)


For android
BASIC VISUALIZATION RULES

Make sure to import the matplotlib.pyplot library by giving the


command:
import matplotlib.pyplot as plt

 Choose an appropriate plot type.


Label the axis
Title of the plot
Add text or arrow at relevant data points.
Use some colours to make the plot more informative.
TYPES OF VISUALIZATION
There are many types of visualization available
with matplotlib.
1. Line plot
2. Scatter plot
3. Histogram
4. Box plot
5. Bar chart
6. Pie chart
BASIC NOMENCLATURE OF A
PLOT

1. Axis
2. Labels
3. Title
4. lengends
LINE CHART

The line chart is represented by a series of datapoints


connected with a straight line.Generally line charts are
used to display trends over time. A line chart or line
graph can be created using the plot() function
available in pyplot library.We can not only just plot a
line but we can explicitly define the grid, the x and y
axis scale and labels, title and display options.
LINE CHART
In order to draw a line plot the steps to be followed
are:
1. Importing matplotlib
2. plt.plot(x,y,color)#plot y versus x as lines or markers
3. plt.xlabel(“your text”)#set the x label
4. plt.ylabel(“your text”)#set the y label
5. plt.set_title(“your title”)#set title
6. Plt.show()#display the plot
LINE CHART
To plot a simple line chart using two lists
import matplotib.pyplot as plt
plt.plot([1,2,3],[5,7,4])#plotting two
lists
plt.show()#displaying the chart

RESULT
MULTIPLE PLOTS
To add legends,titles & labels to a
line plot with multiple lines

RESULT
LINE CHART
To plot frequency of marks using line
chart:

RESULT
PIE CHART
A pie graph/pie chart is a specialized graph
used in statistics. The independent variable is
plotted around a circle.Pie Charts shows
proportions and percentages between
categories, by dividing a circle into proportional
segments/parts. Each arc length represents a
proportion of each category, while the full circle
represents the total sum of all the data, equal
to 100%
BAR CHART
A bar chart/bar graph, is a very
common two-dimensional data
visualization made up of rectangular
bars, each for a specific category and
it’s length represents the value of that
category.
BAR CHART
To plot a simple bar chart

RESULT
SCATTER PLOT
It uses dots to represent the values
obtained for two different variables.
It is a collection of points not connected
by lines
Used to identify association between
two variables.
SCATTER PLOT
To plot scatter chart for height vs
weight of the students
HISTOGRAMS

Histogram is an accurate graphical


representation of the distribution of
numerical data.
It is an estimate of the distribution of a

Continuous variable.
HISTOGRAMS
To plot a histogram of random values.

RESULT
RESULT
BOX PLOT
Box plots are descriptive diagrams that help compare
the distribution of different series of data.

It includes:
Minimum
First quartile(Q1)
Median(second quartile-Q2)
Third quartile(Q3)
Maximum
BOX PLOT
Quartile:

A quartile is a quantity which divides the


distribution of data into four equal parts
To find a quartile:
1. Arrange the data in ascending order.
2. Count the number of observations.
3. Convert any percentage to a decimal for “q”
4. Insert your values into the formula
(i)th observation=q(n+1)
BOX PLOT
To plot a simple box plot:

RESULT
BOX PLOT
NOTCH:
NOTCH is a logical attribute
It narrows Box around the median
It displays a confidence interval around the
median.
It is used to compare groups
If Notches of two boxes doesn’t overlap it
means their medians differ.
BOX PLOT
To plot a NOTCH boxplot:

RESULT
Thanks!

You might also like