Revision Notes of Data Visualization With Ws.docx
Revision Notes of Data Visualization With Ws.docx
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
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:
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
(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()
(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")