Dataa
Dataa
2. Pyplot is amodule in the matplotlib package. From matplotlib import pyplot as plt
3. The matplotlib API is imported using the standard convention X=[4,8,3]
4. The _____ is bounding box with ticks and labels. Ans. Axes Y=[1,6,9]
5. The _____ can be plotted verticall or horizontally. Ans. bar chart plt.plot(X,Y)
6. Histograms are used to show a/an ____________. Ans. Distribution plt.title(‘Details)
7. To add a tittle in a chart, ____________ function is used. Ans. tittle() plt.ylabel(‘Y axis’)
8. A bar graph uses bars to compare data among ________. Ans. different categories. plt.xlabel(‘X axis’)
9. What is Pylab? Ans. Pylab is a package that combine numpy,scipy ad matplotlib into a single namespace. plt.show( )
10. Mr.Sanjay wants to plot a bar graph for the given set of values of subjects on x-axis and number of students who opted 24. Write the output graph of :
for that subject on y-axis. Complete the code to perform the following operation (i) to plot the bar graph in statement 1 import
(ii) to display the graph in statement 2 x = [‘HINDI’, ‘ENGLISH’, ‘SCIENCE’ , ‘SST’] y=[10,20,30,40] ____________ matplotlib.pyplot
# statement 1 ____________# statement 2 Ans. (i) plt.bar(x,y) (iii) plt.show( ) as p
11. How to import matplotlib? Ans. form matplotlib import pyplot as plt. x=[2,3,4,5,6,7]
12. Which of the following is not a valid chart type? a. line b. bar c. histogram d. statistical Ans. d.statistical y=[1,2,3,4,5,6]
13. The command used to show legends is Ans. c.legend() p.plot(x,y)
14. The command used to give a heading to a graph is _________Ans. d.plt.title() p.show()
15. Using Python Matplotlib _________ can be used to count how many values fall into each interval Ans. c. histogram
16. 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 number.
import matplotlib.pyplot as PLINE LIST=[10,20,30,40,50,60] ______________ #statement 1 _____________
#statement 2 Ans. (i) PLINE.plot(LIST) (i) PLINE.ylabel(“Sample number”) 25. Write code to plot a line graph showing the relation between channel name and its TRP rating ( 4 channels). Include the
17. In matplotlib, what is ticks? Ans. A standard graph shows the marks on the axis, in matplotlib library, it is called ticks. titles and formatting of your choice. The font size of the x and y labels should be 15 and font color should be green
18. What is the use of label in plotting? Ans. Label is used to add labels or names to respective x and y axis. import matplotlib.pyplot as p
19. _____ are specified as consecutive, non overlapping intervals of a variable, mainly used in histograms. Ans. ii) Bins x=["Sony","Star","SAB","Zee"]
20. Assuming that a line chart is plotted on x and y axis, write the command to give title as ‘New Graph’ using Plt object y=[60,40,55,35]
Ans. Plt.title(‘New Graph’) p.plot(x,y, linestyle=":")
21. Consider the following graph. Write the code to plot it p.title('TRP of various channels')
Ans. import matplotlib.pyplot as plt a = [0,1,2,3,4,5] b = p.xlabel('Name of Channel',fontsize="15",color="green")
[10,31,26,24,20] plt.plot(a,b) plt.show() p.ylabel('TRP',fontsize="15",color="green")
p.show(
26. Consider the following graph. Write a program in python to draw it along with proper labeling of X-axis, Y-axis and
Title for the line Chart of your choice
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-2, 2,50)
22. Write code to y=x*x
draw the following bar graph representing the number of students in each plt.plot(x,y)
class. plt.title('Y = x * x')
Ans. import matplotlib.pyplot as plt Classes = ['VII','VIII','IX','X'] plt.xlabel('X-Axis')
Students = [40,45,35,44] plt.barh(classes, students) plt.show() plt.ylabel('Y-Axis')
plt.show()
41. Which of the following is the correct syntax to create a histogram with bins specified? a. plt.hist(x, bins=10) b.
plt.hist(x, bins=[10,11,12,13,14]) c. plt.hist(x, bins=range(10,15)) d. All are correct
42. If you install Python IDLE, Matplotlib is installed automatically. a. True b. False
43. The command to install Matplotlib library in python is: Pip install matplotlib
30. Look at the following graph and select appropriate code to obtain 44. In the given chart, the box surrounded by a red border is called: Y label
this output. (Please assume that pandas and matplotlib is already imported)"
zone = [1, 2, 3, 4]
schools = [230, 430, 300, 140]
plt.plot(schools, zone)
plt.title("School Survey")
plt.show()
31. which of the given statements is incorrect regarding data
visualization. Visualizing large and complex data does not produce
effective results
32. Matplotlib is ____ plotting library b. 2D 45. Select the correct statement to display a horizontal box plot: plt.boxplot(data, vert=False)
33. Data __________ refers to graphical representation of data. Visualization 46. The value of _______ chart is calculated in terms of percentage. d. Pie
df1.plot(kind = 'bar')
plt.show()
plt.scatter(df1['1990'], df1['2010'])
plt.plot(sname, smarks)
plt.xlabel('Student Name')
plt.ylabel('Marks Scored')
plt.show()
import numpy as np
A = np.arange(2, 20, 2)
B = np.log(A)
C = np.log(A) * 1.2
plt.plot(A, B)
plt.plot(A, C)
plt.show()
plt.bar(hobbies, people_count)
plt.xlabel('Hobbies')
plt.ylabel('Number of People')
plt.title('Favourite Hobby')
plt.savefig('favourite_hobby_chart.png')
plt.show()