RT 4 Ip 065
RT 4 Ip 065
RT 4 Ip 065
REVISION TEST IV
INFORMATICS PRACTICES (065)
1. Consider the following line graph. Write the code to plot it.
6
0
2 3 4 5 6
2. Consider the following bar graph. Write the code to plot it.
8
6
4
2
0
1 2 2 4
3. Given an array Rev storing Revenue of a small business in past some years:
Rev= np.array([12, 15, 13, 15, 16, 17, 14, 19, 19, 17, 19, 16, 17, 16, 18, 18, 18, 19, 19, 18, 19,21,
20, 18, 19, 19, 21, 19, 19, 22]).
(a) Write code to create a histogram as per following specifications:
i) Number of bins should be 10. ii) Plot color should be blue. iii) Outline/edge color should be red
(b) Create a step type histogram.
4. i)Create a histogram that plots two ndarrays x and y with 48 bins, in stacked horizontal
histogram. ii) Add plot title and axes titles to above plot.
5. Write a code to plot the speed of a passenger train as shown in the figure given below:
100%
Slow
50%
Fast
0% Normal
2 4 6 8
Write code to draw the multiple bar chart showing states on the x axis and
production of various agricultural products on the y axis.
3. Questions given below are based on the following data:
1. (b) matplotlib.pyplot
2. (d) All of these
3.(a) X values
4. (b) title()
5. (b) plt.show()
6. c) pyplot
7. (a) subplots
8. (b) set_title
9. (d) set_ylabel
10. (a) plt.show()
11. Which method is used to save the output of pyplot in the form of image file?
11. A. savefig(‘filename’)
12. B. data presentation architecture
13. D. All of the above
14. A. It can be accessed quickly by a wider audience.
15. A. matplotlib.pyplot
16. A. show()
17. C. hbar()
18. B. hist()
SECTION B
1. Library – matplotlib
interface – pyplot
2. You can import matplotlib in following two ways:
1. Using alias name: import matplotlib.pyplot as pp
2. Without alias name: import matplotlib.pyplot
3 The chart has following elements/components:
1. Chart area or figure
2. Axis
3. Titles
4. Legends
4 The matplotlib provides following types of charts:
1. Line chart
2. Bar chart
3. Horizontal bar chart
4. Histogram
5 To change the thickness of line, use the linewidth parameter inside matplotlib.pyplot.plot()
To change the line style, use linestyle parameter.
6 import matplotlib.pyplot as plt
game=[ “Subway Surfer”, “Temple Run”, “Candy Crush”, “Bubble Shot”, “Runner Best”]
rating=[4,5,2,5,8]
plt.bar(game,rating)
plt.xlabel(“Games”)
plt.ylabel(“Rating”)
plt.show()
7. import matplotlib.pyplot as plt
import numpy as np
means = [20, 35, 30, 35, 27]
stds = [2, 3, 4, 1, 2]
indx = np.arange(len(means))
plt.bar(indx, means, color = 'cyan', label = 'Means')
plt.bar(indx+0.25, stds, color = 'olive', label = 'Stds')
plt.legend()
plt.show()
SECTION C
SECTION D
1. import matplotlib.pyplot as plt
X=[1,2,3,4,5]
plt.plot(X,df[“Quarter1”, label=” Quarter1”)
plt.plot(X,df[“Quarter1”, label=” Quarter2”)
plt.plot(X,df[“Quarter1”, label=” Quarter3”)
plt.plot(X,df[“Quarter1”, label=” Quarter4”)
plt.legend()
plt.show()