**Contents**show

## data visualization with python class 12 notes

### MATPLOTLIB:-

it is a python library which provides many interfaces and functionality for 2D graphics like MATLAB.

### pyplot:-

it is a collection of method within matplotlib library of python. which allow user to construct 2D plot easily and intellectually.

### data visualization:-

it refers to graphical representation of information and data using visual elements like charts, graphs and maps.

### types of charts

1.line chart

2.bar chart

3. pychart

### Line Chart:-

The line chart is represented by a series of data points connected

with a straight line.

line charts are used to display trends over time.

A line chart or line graph can be created

using the plot()

function available in pyplot library.

### Python Program to Draw a Line Chart

import matplotlib.pyplot as plt

import numpy as np

x = [‘Delhi’, ‘Banglore’, ‘Chennai’, ‘Pune’]

y = [250, 300, 260, 400]

plt.xlabel(‘City’)

plt.ylabel(‘Sales in Million’)

plt.title(‘Sales Recorded in Major Cities’)

plt.plot(x, y)

plt.show()

### output of the program

### Bar Chart

A bar chart/bar graph, is a very common two-dimensional data visualization made up of rectangular bars,

each for a specific category and it’s length represents the value of that category.

Python Program for bar graphs

import matplotlib.pyplot as plt

x = [‘Delhi’, ‘Banglore’, ‘Chennai’, ‘Pune’]

y = [250, 300, 260, 400]

plt.xlabel(‘City’)

plt.ylabel(‘Sales in Million’)

plt.title(‘Sales Recorded in Major Cities’)

plt.bar(x, y)

plt.show()

### output of program

### Pie Chart:-

A pie graph/pie chart is a specialized graph used in statistics.

The independent variable is plotted around a

circle.

Pie Charts shows proportions and percentages between categories, by dividing a circle into proportional

segments/parts.

Each arc length represents a proportion of each category, while the full circle represents the total sum of all the data, equal to 100%.

### Program to draw Pie-chart

import matplotlib.pyplot as plt

import numpy as np

x = [‘Delhi’,’Banglore’,’Chennai’,’Pune’,’Ghaziabad’,’Udupi’]

y = [250,300,260,400,599,320]

plt.pie(y,labels=x,autopct=’%1.2f’,startangle=90,explode=(0,0.1,0,0,0.2,0))

plt.show()

### output of the Python Program

### numpy:-

numpy is the core library for scientific computing in python.

It provides a high performance,

multidimensional array object and tools for working with

these arrays.

#### module to be imported:-

import numpy as np

### example

1. np.arrange(11) output:- [0 1 2 3 4 5 6 7 8 9 10]

2.np.arrange(1,10,2) output:- [1 3 5 7 9]

3.np.arrange(-10,15,3) output:- [-10 -7 -4 -1 2 5 8 11 14]

4.np.zeros(5) output:- [0 0 0 0 0]

## 2 thoughts on “data visualization with python class 12”