Here is class 12 computer science Unit 8 [Type A] solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 8 and for all chapters here. Watch all tutorials for chapter 8.
Data visualization help us to have a visual representation of the data like bar, chart, map etc. It simply makes the analyses of the massive and large data in easy and appropriate manner.
It makes us to pick the trend and result out of the raw data for decision-making information.
Python enables its library namely matplotlib.pyplot which having large number of effective 2D and also 3D plot for data visualization.
matplotlib is python library that is having a numerous 2D and 3D various plotting features like bar, chart, pie, graph etc. It allows to have a visual display of the data and also publish ready figure to show results.
matplotlib having many interfaces for the visualizing of data and pyplot is one of them.
A ndarray refers to numpy array that is a grid of values, all of the same type, and is indexed by a tuple of non-negative integers.
A list is the Python equivalent of an array, but is resizeable and can contain elements of different types.
Also in numpy is highly extensive management of number and highly recommendable due to good performance than list.
pyplot offer a function bar() for plotting bar graph of vertical and horizontal orientation but by default it plots vertical bar graph of various length and visual bars.
barh() is a function of pyplot that plot horizontal bar graph in specific manner.
When we are plotting various plot in same figure of different feature by giving separate label to them than legend() function enable to publish the title at given position to distinguishing the separate feature plot by various parameter (colour, shape, style etc.)
In this a warning will arise i.e. “No handles with labels found to put in legend“.
xlimit and ylimit are function of pyplot that just shrink or limit the x-axis and y-axis plot to the given parameter in the function call.
plt.xlim([20,80]) #this will display x-axis in between 20 to 80 plt.ylim([5.0, 15.0]) #this will display y-axis in between 5 to 15
Line graphs can also be used to compare changes over the same period of time for more than one group.Pie charts are best to use when we are trying to compare parts of a whole.Bar graphs can be used where we want a tally record of same thing over a long period.
L1 = list(range(0,11,2)) L2 = [i*3 for i in L1]
L1 = np.array((range(0,11,2))) L2 = numpy.array(L1)*3
Bar graph and scatter plot can be choice for this plot as it will give a comparative view of temperature on the seven days of the last week. Most preferable bar graph will be opted.
import matplotlib.pyplot as plt simple = [] curve = [] higher_curve = [] for i in range(20): simple.append(i) curve.append(i*2) higher_curve.append(i*3) plt.plot(list(range(20)), simple ) plt.plot(list(range(20)), curve) plt.plot(list(range(20)),higher_curve) plt.legend() plt.show()
(a) A bar graph will be an appropriate way to plot the data.(b) In this a direct compare of the all quarter for various company will de done easily.(c) Yes, we can have three pie charts each for the different city branch.
import matplotlib.pyplot as plt import numpy as np curve = [] for i in range(20): curve.append(i*2) #Line chart plt.plot(list(range(20)), curve) plt.show() #bar graph plt.bar(list(range(20)), curve) plt.show() #pie chart langs = ['C', 'C++', 'Java', 'Python', 'PHP'] students = [23,17,35,29,12] plt.pie(students, labels = langs,autopct='%1.2f%%') plt.show()
Clear Doubts with Computer TutorIn case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in
You cannot copy content of this page