# Data Visualization Class 12 Notes

Teachers and Examiners (CBSESkillEduction) collaborated to create the Data Visualization Class 12 Notes. All the important Information are taken from the NCERT Textbook Computer Science (083) class 12.

Contents

## Data Visualization Class 12 Notes

### What is Data Visualization

The process of displaying data in the form of graphs or charts is known as data visualisation. It makes it incredibly simple to understand big and complex volumes of data. It makes decision-making very efficient and makes it simple for decision-makers to spot emerging trends and patterns. We can utilise a variety of Python data visualisation libraries, like Matplotlib, Seaborn, Plotly, etc.

#### Using Pylot of Matplotlib Library

The Python low-level package Matplotlib is used for data visualisation. It is simple to use and replicates the graphs and visualisation found in MATLAB. This library is composed of numerous plots, including line charts, bar charts, histograms, etc.

An interface similar to MATLAB is offered by the Matplotlib package Pyplot. Because it supports Python and is free and open-source, Matplotlib is intended to be just as functional as MATLAB. Each Pyplot function modifies a figure in some way, such as by creating a figure, a plotting region within the figure, some lines within the plot area, labelling the plot, etc.

Data Visualization Class 12 Notes

#### Installing and Importing matplotlib

Your machines already have the matplotlib library loaded if you installed Python using Anaconda. By launching Anaconda Navigator, you may verify it for yourself. Click Environments in the Navigator box, then scroll down then you can find list of installed software on your machine.

Data Visualization Class 12 Notes

#### Using NumPy Array

NumPy (‘Numerical Python’ or ‘Numeric Python’, pronounced as Num Pie) is an open source module of Python that offers functions and routines for fast mathmaatical computation on arrays and matrices. In order to use NumPy, you must import in your module by using a statemnt like –

import numpy as np

Code
import numpy as np
list = [1, 2, 3, 4]
a1 = np.array(list)
print(a1)

Data Visualization Class 12 Notes

#### Ways to create NumPy arrarys

a) Creating a One-dimensional Array
To create a One dimensional Array the arange function is frequently used to quickly build an arrary. The arange method generates an array with values from 0 to 9 when given a value of 10.

Example
import Numpy as np
array = np.arange(20)
array

Output
array([0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14,
15, 16, 17, 18, 19])

Data Visualization Class 12 Notes

b) Creating a Two-dimensional Array
Let’s discuss how to make a two-dimensional array. The output of the arange function, when used alone, is a one-dimensional array. Combine its output with the reshape function to convert it to a two-dimensional array.

Example
array = np.arange(20).reshape(4,5)
array

Output
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19]])

Data Visualization Class 12 Notes

#### Creating Charts with Matplotlib Library’s Pyplot interface

You know that graphs and charts play a big and an important role in data visualization and decision making. Every chart type has a different utility and serves a different purpose.
a) Line Chart – 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. The PyPlot interface offers plot() function for creating line graph.

Example
import matplotlib.pyplot as plt
x = [5, 10, 20, 30]
y = [10, 15, 25, 35]
plt.plot(x, y)
plt.title(“Line Chart”)
plt.ylabel(‘Y-Axis’)
plt.xlabel(‘X-Axis’)
plt.show()

b) Bar Chart – A bar Graph or a Bar Chart is a graphical display of data using bars of different heights. A bar chart can be drawn vertically or horizontally using rectangles or bars of different heights/ widths PyPlot offer bar() function to create a bar chart.

Example
import matplotlib.pyplot as plt
x = [5, 10, 20, 30]
y = [10, 15, 25, 35]
plt.plot(x, y)
plt.title(“Line Chart”)
plt.ylabel(‘Y-Axis’)
plt.xlabel(‘X-Axis’)
plt.show()

Data Visualization Class 12 Notes

c) The Pie Chart – Recall that a pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. Typically, a Pie Chart is used to show parts to the whole, and often a % share. The PyPlot interface offers pie() function for creating a pie chart.

Example
import matplotlib.pyplot as plt
x = [5, 10, 20, 30]
y = [10, 15, 25, 35]
plt.plot(x, y)
plt.title(“Line Chart”)
plt.ylabel(‘Y-Axis’)
plt.xlabel(‘X-Axis’)
plt.show()

error: Content is protected !!