0% found this document useful (0 votes)
1 views25 pages

data-visualisation-using-pyploteng

The document outlines the learning objectives and concepts of data visualization using Pyplot as per the CBSE curriculum for Class 12. It explains the importance of data visualization, introduces the Matplotlib library and its Pyplot interface, and details how to create various types of charts such as line charts, bar charts, and histograms. Additionally, it covers customizing chart attributes like color, width, and adding titles and legends.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views25 pages

data-visualisation-using-pyploteng

The document outlines the learning objectives and concepts of data visualization using Pyplot as per the CBSE curriculum for Class 12. It explains the importance of data visualization, introduces the Matplotlib library and its Pyplot interface, and details how to create various types of charts such as line charts, bar charts, and histograms. Additionally, it covers customizing chart attributes like color, width, and adding titles and legends.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Data Visualization using Pyplot

As per CBSE curriculum


Class 12
Learning Objectives

• Understand Data Visualization


• Learn chart types
• Create charts using Matplotlib & Pandas
• Select the correct chart
What is Data Visualization?

• “Data Visualization basically refers to the


graphical or visual representation of data
using visual elements like chart, graph and map
etc.
• Visualization techniques of such big data are
very important for the purpose of analysis of
data.
• And this Data is very important for any
organization for decision making.
Data Visualization
“Data Visualization basically refers to the graphical or
visual representation of information and data using
visual elements like charts, graphs or maps.
• In this chapter we will come to know about Pyplot in
Python.
• We will also come to know about the visualization of
data using Pyplot.
Use of Pyplot of MATPLOTLIB Library
• The Matplotlib is a python library that provides many
interfaces and functionality for 2D-graphics similar to
MATLAB.
• We can call it as high quality ploting library of
python.
• Matplotlib library offers many different named
collections of methods; Pyplot is one such interface.
• Pyplot is a collection of methods within matplotlib
which allow us to construct 2D plots easily and
interactively.
Installing and importing Matplotlib
Importing Pyplot
• Following syntax need to write to import Pyplot
import [Link]
OR
import [Link] as pl
• We will use commands afterwards using pl with
(.).
• Before proceeding we need to know something
about numpy.
• Numpy provides very useful functions for ploting.
• Numpy also supports vectorized functions.
Basics of Simple Plotting
• Graphical representation of compiled data is known
as data visualization.
• Chart and Graph are very important tools for data
visualization.
• Pyplot can be used for developing various types of
graphs and charts.
• We will go through following charts in syllabus-
– Line chart
– Bar Chart
- Histogram
Creating 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 a straight line segments.
• The pyplot interface offers plot() function for creating
a line graph. -
Creating Line Chart
• Let’s take an example – here we have data of runs made in 5
overs. We will name X axis as overs and Y axis as runs.
We will use these
functions for labeling.

Labels are shown in


resultant chart.
Setting of Line color, width and style
• It has following syntax -
[Link](<data1>,<data2>,<color code>)
‘r’ is used for Red color
and ‘b’ is used for blue
color.

Both the
colors are
shown in
resultant
chart.
Changing Line color, width and style
• It has following syntax -
[Link](<data1>,<data2>,linewidth=<val>…)

Use ‘:’ , ‘-’ , ‘--’ ,


‘-.‘ for different line
styles.
Changing Marker type, size and color
-It has following syntax -
[Link](<data1>,<data2>,linestyle=<val>…)

[Link]
[Link] A use full Link to understand pyplot
Creating Bar Chart
• A Bar Graph /Chart a graphical display of data using bars of
different heights. Syntax is– [Link](a,b)
These functions are used
for labeling.

Labels are shown in


resultant chart.
Changing Bar width
• A Bar Graph /Chart a graphical display of data using bars of
different heights. Syntax is–
[Link](a, b, width=<Value>)

It is also possible to set the different width of bars


for different data.
Changing Bar color
• A Bar Graph /Chart a graphical display of data using bars of
different heights. Syntax is–
[Link](a, b, color=<code>)
Creating Multiple Bar Chart

The fact to notice here is that the number


of times you use bar () function before
calling Show() Function, it will be added to
the same chart.
Creating Horrizontal Bar Chart

barh() function is being used here.


Histogram
Histogram shows distribution of values. Histogram is similar to bar graph
but it is useful to show values grouped in bins or intervals.
For example- we can collect the age of each employee in an office and show it
in the form of a histogram to know how many employees are there in the
range 0-10 years, 10-20 years and so on. For this we can create histogram
like this-

Output-

rwidth=0.6
means that the
bars width is 60%.
There will be a
ga p of 4 0 % space
before and after
Example 2-
the bar.
Note- edgecolor is used to define the color of edge around
bar
Anatomy of Chart
• Chart has a structure. See the following points-
• Figure – Any chart will be made under this area only. This
is the area of plot.
• Axes – This is that area which has actual ploting.
– Axis Label – This is made up of x-axis and y-axis.
– Limits – This is the limit of values marked on x-axis and y-axis.
– Tick Marks – This is the individual value on x-axis and y-axis.
• Title – It is the text to be shown at the top of plot.
• Legends – This is the set of data of different color which is
to be used during plotting.
Adding Title and setting xlimit & ylimit

[Link] () and [Link] () functions are used


here.
Adding Legends

Legends Legends
Saving a Figure

This line will be written to


save the figure of Plotting.
Thank you

You might also like