KENDRIYA VIDYALAYA
I.N.S. CHILKA
Name: Arik Khutia
Class: XI Commerce
Roll no.: 11
Subject: Informatics Practices
Subject Teacher: V. K. Mehra Sir
Topic:
Data Visualization
What is Data Visualization?
❖ Data visualization refers to the graphical or visual
representation of information and data using visual
elements like charts, graphs , maps etc.
❖ It is immensely useful in decision making to un-
derstand the meaning of data to drive business deci-
sion.
❖ For data visualization in Python, the Matplotlib
library’s pyplot is used.
Working with pyplot methods!
➲ The pyplot interface provides many methods for
2D plotting of data in multiple ways such as line
chart, bar chart, pie chart, scatter chart etc.
➲ But before proceeds, it is recommended to have
an idea of using numpy library and some of it s
functions, as:
➢ Numpy offers some useful function to create
arrays of data, which provides useful while
plotting data.
➢ Numpy arrays which is like a list supports
vectorized operation that is not supported by
list object in python.
Vectorized Operation
Comparison: Array vs. List
❖ Both the data structures allow indexing, slicing, iterating and
mutability.
But:
❖ List is built-in data structure in python where as to use an ar-
ray in Python, we need to import this data structure from the
NumPy package.
❖ List does not support vectorized operation while array sup-
ports the same.
❖ Arrays are great for numerical operations with compared to
list
❖ Lists can be re-sized where array can not be
❖ List is heterogeneous where array is homogeneous structure
Creating NumPy Array
Plotting the values
Commonly used chart type:
Customization of Plot( )
import [Link] as plt
x = [1,2,3,4,5,6]
y = [2,4,1,5,2,6]
[Link](x, y, color='green', linestyle='dashed', linewidth = 3,
marker='o', markerfacecolor='blue', markesize=12)
[Link](1,8)
[Link](1,8)
[Link]('x - axis')
[Link]('y - axis')
[Link]('customizations!')
[Link]()
What is legend?
The legend of a graph reflects the data displayed in the
graph's Y-axis, also called the graph series.
With a chart, a legend is an area of a chart describing
each of the parts of the chart.
A Legend is a representation of legend keys or entries
on the plotted area of chart or graph which are linked to the
data table of the chart or graph.
BAR CHART
import [Link] as plt
langs = ['C', 'C++', 'Java', 'Python',
'PHP']
students = [23,17,35,29,12]
[Link](langs, students, color =
['red', 'green',‘ blue',
‘magenta', 'orange'])
[Link]('Languages')
[Link]('Number of Student')
[Link]('Admission Info in each
course')
[Link]()
HISTOGRAM
import [Link] as plt
# frequencies
Ages=[2,5,70,40,30,45,50,45,43,40,44,60,7,13,
57,18,90,77,32,21,20,]
# setting the ranges and no. of intervals
range = (0, 100)
bins = 10
# plotting a histogram
[Link](ages, bins, range, color = 'green',
histtype = 'bar', rwidth=0.8)
[Link]('age')
[Link]('No. of people')
[Link]('My histogram')
[Link]()
SCATTER DIAGRAM
import [Link] as plt
# x-axis values
X = [1,2,3,4,5,6,7,8,9,10]
# y-axis values
Y = [2,4,5,7,6,8,9,11,12,12]
# plotting points as a scatter plot
[Link](x,y,label="Stars",color
= "red", marker= "*",s=80)
PIE CHART
import [Link] as plt
activities = ['eat', 'sleep', 'work', 'play']
slices = [3, 7, 8, 6]
colors = ['r', 'y', 'g', 'b']
# plotting the pie chart
[Link](slices,labels=activities,colors=
colors,startangle=90,shadow=True,auto
pct = '%1.1f%%')
[Link]()
[Link]()