CHAPTER -3
WORKING WITH PYPLOT
TOPICS: CHART TYPES,LINE AND SCATTER CHART
OBJECTIVE TYPE QUESTIONS
1)A _________ refers to the graphical representation of data and information using charts or
diagrams or maps.
2)The ______ module allows you to represent data visually in various forms.
3)The ________ library provides the interface and functionality for plotting the graphs.
4)Which of the following offers many different names collections of methods?
a) PyPlot b) matplotlib c) matlab d) graphs
5)Which of the following correct statement to import pyplot module?
a) import matplotlib.pyplot b) import MatPlotLib.PyPlot
c) import PyPlot as pl d) import pyplot.plot
6)A bar chart is also known as column chart. (True/False)
7)Which is a common method used to plot data on the chart?
a) plot() b) show() c) legend() d) title()
8)The pl.show() method must be used to display the chart in the end of the chart
specification. (True/False)
9)To change the width of bars in bar chart, which of the following argument with a float
value is used?
a) thick b) thickness c) width d) barwidth
10)Which method is used to display or show the legends?
a) pl.show() b) pl.display() c) pl.legend() d) pl.values()
SUBJECTIVE TYPE/PRACTICAL RELATED QUESTIONS
1)What do you mean by data visualization technique?
2)Name the library and interface used to plot a chart in python.
3) What types of graphs can be plotted using matplotlib?
4) Write code to plot a line chart to depict the run rate of T20 match from given data:
Overs Runs
5 45
10 79
15 145
20 234
5) How to change the thickness of line, line style, line color, and marker properties of a chart?
6) Mrs. Namrata is a coordinator in the senior section school. She represented data on number of
students who passed the exam on line chart as follows:
She has written the following code but not getting the desired output. Help her by correcting
her code.
import matplotlib.pyplot as plt
classes=["X A","X B","XI A","XI B","XII A","XII B"]
no_of_boys=[23,22,20,26,33,30]
no_of_girls=[17,10,20,12,5,8]
plt.line(classes,no_of_boys) #Statement 1
plt.line(classes,no_of_girls) #Statement 2
plt.xtitle("No of Stduents") #Statement 3
plt.ytitle("Classes") #Statement 4
plt.show()
i) What will be the correct code for Statement 1 and Statement 2?
ii) What is the correct function name for Statement 3 and Statement 4?
iii) Write a method and parameter required to display legends?
iv) Name the parameter and values used to apply the marker as given in the output.
v) Name the parameter and values used to apply linestyle as given in the output.
vi) How to apply the line colours as given in the figure?
vii) Write to save the figure as image.