12th Standard Syllabus & Materials
12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set C
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set B
NEW12th Standard
TN 12th Standard Biology Zoology - Reproduction in Organisms Creative Questions Study Material - QB365 Set A
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set C

Published on: 14/10/2019
Data Visualization Using Pyplot: Line Chart, Pie Chart and Bar Chart
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
Write a python code to display the following plot.
2.
Write the plot for the following pie chart output.
3.
Write the coding for the following:
a. To check if PIP is Installed in your PC.
b. To Check the version of PIP installed in your PC.
c. To list the packages in matplotlib.
4.
Write any three uses of data visualization.
5.
Draw the output for the following data visualization plot.
import matplotlib.pyplot as plt
plt.bar([1,3,5,7,9],[5,2,7,8,2], label="Example one")
plt.bar([2,4,6,8,10],[8,6,2,5,6], label="Example two", color='g')
plt.legend()
plt.xlabel('bar number')
plt.ylabel('bar height')
plt.title('Epic Graph in Another Line! Whoa')
plt.show()
6.
Write s python code to display to following plot.
Program
7.
Write the key differences between Histogram and bar graph.
8.
Write a python code to display the following, plot.
9.
Explain the purpose of the following functions:
a. plt.xlabel
b. plt.ylabel
c. plt.title
d. plt.legend()
e. plt.show()
10.
Explain in detail the types of pyplots using Matplotlib.
1.
Program:
For example, to plot x versus y, you can issue the command:
import matplotlib. pyplot as plt
pIt.plot([1,2,3,4], [1,4,9,16])
plt.show ( )
Output:
2.
Plot:
import matplotlib.pyplot as plt
sizes = [105, 30, 30, 195]
label= ["sleeping", "eating", "working", "playing"]
plt.pie (sizes, labels = labels, autopct = "%.2f")
plt, axes ( ). set_aspect ("equal")
plt.show ( )
3.
(a) Check if PIP is Installed:
To check if PIP is already installed in our system, navigate our command line to the location of Python's script directory.
Command:
Python m pip install - U pip.
(b) To check PIP version:
To check the version of PIP in our system, type the command as:
C: \Users\Your Name\App Data\Local\Programs\Python\Python 36-32\Scripts> Pip--version.
(c) List packages:
To view the list of installed packages on our system, use the list command:
C:\Users\Your Name\App Data\Local\Programs\Python\Python 36-32\scripts> Pip list
4.
(i) Data Visualization help users to analyze and interpret the data easily.
(ii) It makes complex data understandable and usable.
(iii) Various Charts in Data Visualization helps to show relationship in the data for one or more variables.
5.
6.
Program:
import matplotlib.pyplot as plt
x = [1,2,3]
Y = [5,7,4]
x2 = [1,2,3]
y2 = [10,14,12]
plt.plot(x, y, Iabel='Line 1')
plt.plot(x2, y2, Iabel='Line 2')
pIt.xlabel('X -Axis')
pIt.yIabel('Y- Axis')
pIt.title('LINE GRAPH')
plt.legend ( )
plt.show ( )
7.
| S.No | Histogram | Bar graph |
| i) | Histogram refers to a graphical representation; that displays data by way of bars to show the frequency of numerical data. | A bar graph is a pictorial representation of data that uses bars to compare different categories of data. |
| ii) | A histogram represents the frequency distribution of continuous variables. | Conversely, a bar graph is a diagrammatic comparison of discrete variables. |
| iii) | Histogram presents numerical data | Bar graph shows categorical data |
| iv) | Items of the histogram are numbers, which are categorised together, to represent ranges of data. | As opposed to the bar graph, items are considered as individual entities. |
| v) | A histogram, this cannot be done, as they are shown in the sequence of classes. | In the case of a bar graph, it is quite common to rearrange the blocks, from highest to lowest. |
| vi) | The width of rectangular blocks in a histogram mayor may not be same | The width of the bars in a bar graph is always same. |
8.
Program:
import matplotlib.pyplot as plt
sizes = [89, 80, 90, 100, 75]
labels = ["Tamil", "English", "Maths", "Science", "Social"]
plt.pie (sizes, labels = labels, autopct = "%.2f")
plt.axes( ).set aspect ("equal")
pIt.show ( )
9.
(a) plt.xlabel:
plt.xlabel() \(\rightarrow \) specifies label for X - axis
(b) plt.ylabel:
plt.ylabel() \(\rightarrow \) specifies label for Y - axis
(c) plt.title:
plt.title() \(\rightarrow \) specifies title to the graph
(d) plt.show():
Display a figure. When running in Python with its Pylab mode, display all figures and return to the Python prompt.
(e) plt.legend():
Calling legend() with no arguments automatically fetches the legend handles and their associated labels.
10.
Line Chart:
(i) A Line Chart or Line Graph is a type of chart which displays information as a series of data points called 'markers' connected by straight line segments.
(ii) A Line Chart is often used to visualize a trend in data over intervals of time - a time series - thus the line is often drawn chronologically.
Example:
import matplotlib.pyplot as plt
years = [2014, 2015, 2016, 2017, 2018]
total_populations = [8939007, 8954518, 8960387, 8956741, 8943721]
plt. plot ("years, total_populations)
pit. title ("Year vs Population in India")
plt.xlabel ("Year")
pIt.ylabel ("Total Population")
plt.showt (1)
In this program,
Plt.titlet( ) \(\rightarrow\) specifies title to the graph
Plt.xlabelt) \(\rightarrow\) specifies label for X-axis
Plt.ylabel() \(\rightarrow\) specifies label for Y-axis
Output:
Bar Chart:
(i) A Bar Plot (or BarChart) is one of the most common type of plot. It shows the relationship between a numerical variable and a categorical variable
(ii) Bar chart represents categorical data with rectangular bars. Each bar has a height corresponds to the value it represents. The bars can be plotted vertically or horizontally.
(iii) It's useful when we want to compare a given numeric value on different categories. To make a bar chart with Matplotlib, we can use the plt.bar() function.
Example:
import matplotlib.pyplot as plt
# Our data
labels = ["TAMIL", "ENGLISH", "MATHS", "PHYSICS", "CHEMISTRY", "CS"]
usage = [79.8,67.3,77.8,68.4,70.2,88.5]
# Generating the y positions.
y_positions = range (len(labels))
# Creating our bar plot
plt.bar (y_positions, usage)
plt.xticks (y_positions, labels)
plt.ylabel ("RANGE")
plt.title ("MARKS")
plt.show( )
Output:
Labels → specifies labels for the bars.
Usage → Assign values to the labels specified.
Xticks → Display the tick marks along the x - axis at the values represented. Then specify the ladel for each tick mark.
Range → Create sequence of numbers.
Pie Chart:
(i) Pie Chart is probably one of the most common type of chart. It is a circular graphic which is divided into slices to illustrate numerical proportion.
(ii) The point of a pie chart is to show the relationship of parts out of a whole. To make a Pie Chart with Matplotlib, we can use the plt.pief) function.
(iii) The autopct parameter allows us to display the percentage value using the Python string formatting.
Example:
import matplotlib.pyplot as plt
sizes = [89, 80, 90, 100, 75]
labels = ["Tamil", "English", "Maths", "Science", "Social"]
plt.pie (sizes, labels = labels, autopct = "%.2f")
plt.axes().set aspect ("equal")
plt.show( )
Output:
12th Standard Syllabus & Materials
12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set B
NEW12th Standard
TN 12th Standard Physics Electronics and Communication Creative Questions Study Material - QB365 Set A
NEW12th Standard
TN 12th Standard Physics Wave Optics Creative Questions Study Material - QB365 Set D
NEW12th Standard
TN 12th Standard Physics Wave Optics Creative Questions Study Material - QB365 Set C
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards