Important Questions For Plotting with PyPlot Class 12 Informatics Practices (IP)
Note:- Please Click on Question to get the Answer !!
Q1. What is data visualization? What is its significance ?
Q2. What is Python's support for Data visualization?
Q3. What is pyplot? Is it a Python library?
Q4. Name some commonly used chart types.
Q5. Name the functions you will use to create a :-
(i) line chart
(ii) bar chart
(iii) scatter chart.
Q6. Consider the code given below (all required libraries are imported) and the output produced by it. Why is the chart showing one bar only while we are plotting four values on the chart?
import matplotlib.pyplot as plt
a = [3, 6, 9, 12]
b = [30, 48, 54, 48]
plt.xlim(-3, 5)
plt.bar(a,b)
plt.show()
Q7. What changes will you make to the code so that the bars are visible for all four points? But do keep in mind that the x-axis must begin from the point -3.
import matplotlib.pyplot as plt
a = [3, 6, 9, 12]
b = [30, 48, 54, 48]
plt.xlim(-3, 5)
plt.bar(a,b)
plt.show()
Q8. Why is following code not producing any result? Why is it giving errors?
a = range (10, 50, 12)
b = range (90, 200, 20)
matplotlib.pyplot.plot(a, b)
Q9. What changes will you recommend to rectify the error in previous question's code?
Q10. Given an ndarray p as ([1, 2, 3, 4]).
Write code to plot a bar chart having bars for p and p**2 (with red colour) and another bar for p vs p 2 (with blue colour). (assume that libraries have been imported)
Q11. What is scatter chart? How is it different from line chart?
Q12. What is histogram? How is it useful?
Q13. Following code is plotting the desired graph but legends are not showing despite giving the legend() of PyPlot. What could be the reason? Suggest a solution for the problem.
plt.plot(x, y)
plt.plot(x, z)
plt.legend (loc = "upper left")
Q14. Given two arrays namely arr1 and arr2, each having 5 values. Create a scatter chart so that each data points gets a different color, different size. Keep the marker style as square.
Q15. Given a data-frame df as shown below:
import pandas as pd
x = {'speed': [10, 15, 20, 18, 19],\
'meters': [122, 150, 190, 230, 300],\
'weight' :[0.2, 0.3, 0.1, 0.85, 0.0]}
df = pd.DataFrame (x)
print (df)
speed meters weight
0 10 122 0.20
1 15 150 0.30
2 20 190 0.10
3 18 230 0.85
4 19 300 0.00
Write code to create scatter graphs from
(a) speed and meters columns of df
(b) meters and weight columns of df
Q16. Write a program to create a histogram that plots two ndarrays x and y with 48 bins, in stacked horizontal histogram.
Q17. Write code to add plot title and axes titles to above plot.
Q18. Write a program to create a box-plot from the following set of data :
34, 18, 100, 27, 54, 52, 93, 59, 61, 87, 68, 85, 78, 82, 91
Q19. Write a program to create a box-plot from the following set of data :
34, 18, 100, 27, 54, 52, 93, 59, 61, 87, 68, 85, 78, 82, 91
But change the orientation to horizontal.
Q20. Write a program to add title as "Horizontal Boxplot" and y-axis title as "Value -range" to previous box-plot.
Q21. A company randomly generates a weekly winning number (between 0..100) for 10 weeks. An employee of the company wants to plot the sine values of winning numbers (nump.sin() function) on a line chart. Write a program to help him accomplish this.
Q22. Write a Python program to draw line charts from the given financial data of ABC Co. for 5 days in the form a Data Frame namely fdf as shown below :
Q23. Consider following Data-frame prodf.
Write a program to plot a scatter chart with the columns Fruits and Pulses.
Q24. Write a program to plot a scatter graph taking a random distribution in X, Y, Z and W (all three with shape as (100,) having random integers) and plotted against each other.
Q25. Write a program to create a horizontal bar chart for India's medal tally.
Q26. Write a program to create a pie bar chart for India's total medals.
Q27. Prof Awasthi is doing some research in the field of Environment. For some plotting purposes, he has generated some data as :
mu = 100
sigma = 15
x = mu + sigma * numpy.random.randn(10000)
y = mu + 30 * np.random.randn (10000)
Write a program to plot this data on a cumulative bar-stacked horizontal histogram with both x and y.
Q28. Marks of some students in four different subjects are available in four lists. Write a program to plot this data in a filled horizontal box-plot.
Q29. Given two ndarrays. Write a program to plot them in the same line graph and show legends.
Q30. Given four sequences as given below:-
X = [1, 2, 3, 4]
Y = [10, 20, 25, 30]
A = [0.3, 3.8, 1.2, 2.5]
B = [11, 25, 9, 26]
Write a program to plot them in the same chart as:-
• A line graph plotted with X and Y with blue color and having line width as 3.
• A scatter graph plotted with A and B with triangular marker of magenta color.
Q31. Write a program to create a horizontal bar chart from two data sequences as given below:
means [20, 35, 30, 35, 27]
stds = [2, 3, 4, 1, 2]
Make sure to show legends.
Q32. In an engineering college, number of admissions stream wise in the current year are:
Civil 15, Electrical = 35, Mechanical = 40, Chemical = 20, CS = 50
Write a program to print above information on a circular pie chart, creating a wedge for CS stream.
had lunch ahh?.
ReplyDeletei ate biriyani brooo...
ReplyDeleteyou need?..
ReplyDeletebut it already finished...only sambar is having..
ReplyDeletereply broooooooooooooooooooooooooo
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )