CHECK POINT ANSWERS
CH – 3 PLOTTING WITH PYPLOT I – BAR GRAPHS AND SCATTER PLOTS
1. What is data visualisation?
Data Visualisation refers to the graphical or visual representation of information and data using visual
elements like charts, graphs, maps, etc.
2. Name the Python library generally used for data visualisation.
Matplotlib is a Python library that provides many interfaces and functionalities for data visualisation.
3. Is Pyplot a Python library? What is it?
Pyplot is a collection of methods within Matplotlib library which allows user to construct 2D plots easily
and interactively.
4. Which of the following is not a valid plotting function of pyplot?
a. plot()
b. bar()
c. line()
d. pie()
c. line()
5. Which of the following plotting functions does not plot multiple data services?
a. plot()
b. bar()
c. pie()
d. barh()
a. plot()
6. Name the function you will use to create a horizontal bar chart.
The barh() function is used to create a horizontal bar chart.
7. Which argument will you provide to change the following in a line chart?
a. width of the line
b. colour of the line
a. width of the line:
The width of the line can be changed by the linewidth argument.
Syntax: plt.plot(x, y, linewidth = <n>)
Where, <n> any integer.
b. colour of the line:
The colour of the line can be changed by the <colour-code> argument in the plot() function.
Syntax: plt.plot(x, y, <colour-code>)
In place of the colour code argument, the following can be used:
Character Colour Character Colour Character Colour Character Colour
‘b’ Blue ‘m’ Magenta ‘c’ Cyan ‘r’ Red
‘g’ Green ‘y’ Yellow ‘w’ White ‘k’ Black
8. What is a marker? How can you change the marker type and colour in a plot?
Marker is used to specify the marker type being dots, crosses, etc.
To change the marker type, ‘marker’ argument is used in the plot() function and to change the marker
colour the ‘markeredgecolor’ argument is used.
Syntax: plt.plot(x, y, marker = <valid-marker-type>, markeredgecolor = <valid-colour>)
Few of the valid-marker-type arguments are – ‘.’, ‘s’, ‘p’, ‘o’, ‘+’, etc.
Few of the valid-colour arguments are – ‘b’, ‘m’, ‘c’, ‘r’, ‘g’, etc.