0% found this document useful (0 votes)
14 views

Revision Notes of Data Visualization With Ws.docx

Uploaded by

max12342732k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Revision Notes of Data Visualization With Ws.docx

Uploaded by

max12342732k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

REVISION OF DATA VISUALIZATION

CLASS : XII (IP)

DATA VISUALIZATION
 Data visualization basically refers to the graphical or visual
representation of information and data using visual elements like charts,
graphs, maps, etc.
 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.

PARTS OF A CHART:

TYPES OF CHARTS:
1. Line Chart or Line Graph
2. Bar Chart
3. Horizontal Bar Chart
4. Histogram
FUNCTIONS TO BE REMEMBERED
FUNCTION NAME USE SYNTAX

xlabel(), ylabel() To give plt.xlabel(‘Year')


Labels for x plt.ylabel(‘No of visitors’)
Axis and y
Axis
title() To give plt.title('Park Analysis')
Chart title

show() To display the plt.show()


chart

legend() An area plt.legend() -label is expected with X and Y


describing the
elements of the
graph.

TABLE OF THE ABBREVIATIONS USED TO SELECT COLOURS:

TABLE OF THE ABBREVIATIONS USED TO SELECT LINE STYLES:


LINE CHART OR LINE GRAPH
Line plot/chart is a type of plot which displays information as a series of data
points called “markers” connected by straight lines.

plot() function is used to draw line chart.


EXAMPLE:

EXAMPLE:
EXAMPLE:

EXAMPLE:
BAR PLOT/CHART
 A bar chart/bar graph is a very commonly-used two-dimensional data
visualization made up of rectangular bars, each for a specific category,
with its length representing the value of that category.
 It can also be used with two data series.
 The bars can be plotted vertically or horizontally.

EXAMPLE:
EXAMPLE:

HORIZONTAL BAR GRAPH


barh() is used to draw horizontal bar graph.

EXAMPLE:
EXAMPLE:
HISTOGRAM
 Histogram is similar to bar graph but it is useful to show values grouped
in bins or intervals.
 Histogram charts are a graphical display of frequencies, represented as
bars.
 They show what portion of the dataset falls into each category, usually
specified as non-overlapping intervals called bins.

EXAMPLE:
We can collect the age of each employee in a office and show it in the form
of a histogram to know how many employees are there in the range 0-10
years, 10-20 years and so on.
EXAMPLE:
QUESTIONS ON DATA VISULIZATION

1. Fill in the blanks.

(a) Data Visualization refers to the graphical or visual representation of


information and data using visual elements like charts, graphs and maps,
etc.
(b) Pyplot is a collection of methods with matplotlib library which allows the
user to construct 2D plots easily and interactively.
(c) Title is the text that appears on the top of the plot and defines what the
chart is about.
(d) The axes of a plot can be labelled using xlabel() and ylabel() functions.
(e) A histogram is a summarization tool for discrete or continuous data.
(f) Pyplot module’s hist() lets you create histograms.
(g) Barh() function is used to create horizontal bar chart.
(h) bin describe the number of data points that fall within a specified range
of values.
2. Multiple Choice Questions (MCQs)

(a) Which Python package is used for 2D graphics?


(i) matplotlib.pyplot (ii) matplotlib.pip
(iii) matplotlib.numpy (iv) matplotlib.plt

(b) The most popular data visualization library in Python is:


(i) pip (ii) matinfolib (iii) matplotlib (iv) matpiplib

(c) Matplotlib allows you to create:


(i) table (ii) charts (iii) maps (iv) infographics

(f) Which of the following commands is used to install matplotlib for coding?
(i) import plt.matplotlib as plot (ii) import plot.matplotlib as pt
(iii) import matplotlib.plt as plot (iv) import matplotlib.pyplot as plt
(g) Which of the following methods should be employed in the code to
display a plot()?
(i) show() (ii) display() (iii) execute() (iv) plot()

(h) Which of the following statements is used to create a histogram of ‘step’


type with 20 bins?
(i) plt.hist(x, bins=20,histype=“barstacked”) (ii) plt.hist(x, bins=20)
(iii) plt.hist(x, bins=20,histype=“step”) (iv) plt.hist(x, bins=20,histype=hist()

(j) The part of chart which identifies different sets of data plotted on plot by
using different colours is called:
(i) legends (ii) title (iii) axes (iv) figure

3. Mr. Sanjay wants to plot a bar graph for the given set of values of subject
on x-axis and number of students who opted for that subject on y-axis.
[CBSE Sample Paper 2020]
Complete the code to perform the following:
(i) To plot the bar graph in statement 1
(ii) To display the graph in statement 2
import matplotlib.pyplot as plt
x=['Hindi', 'English', 'Science', 'SST']
y=[10,20,30,40]
_____________________ Statement 1
_____________________ Statement 2
Ans. (i) plt.bar(x, y)
(ii) plt.show()
4. Mr. Harry wants to draw a line chart using a list of elements named LIST.
Complete the code to perform the following operations:
(i) To plot a line chart using the given LIST,
(ii) To give a y-axis label to the line chart named “Sample Numbers”.
import matplotlib.pyplot as PLINE
LIST=[10,20,30,40,50,60]
_____________________ Statement 1
_____________________ Statement 2
PLINE.show()
Ans. (i) PLINE.plot(LIST)
(ii) PLINE.ylabel("Sample Numbers")

5. Write a code to plot the speed of a passenger train as shown in the


figure given below:

Ans. import matplotlib.pyplot as plt


import numpy as np
x = np.arange(1, 5)
plt.plot(x, x*1.5, label='Normal')
plt.plot(x, x*3.0, label='Fast')
plt.plot(x, x/3.0, label='Slow')
plt.legend()
plt.show()

You might also like