SlideShare a Scribd company logo
2
2
Step 2 import module
Import matplotlib.pylot using import command in the following two ways:
1. Without instance
import matplotlib.pyplot
2. With instance
import matplotlib.pyplot as mpp
Step 3 Choose desired plot type (graph type)
In this step, select your desired chart type for plotting. For example, line chart
Step 4 Give proper labels to axis, categories
A graph is made up of two-axis i.e. X and Y-axis. In this step label them as per the need as well as apply proper
labels for categories also.
Step 5 Add data points
The next point is to add data points. Data points depict the point on the plot at a particular place.
Step 6 Add more functionality like colors, sizes etc
To make your graphs more effective and informative use different colors and different sizes.
The common method used to plot a chart is plot().
The Pyplot package provides an interface to plot the graph automatically as per the requirements. You just need
to provide accurate values for axes, categories, labels, title, legend, and data points.
Matplotlib provides the following types of graphs in python:
 Line plot
 Bar graph
 Histogram
 Pie chart
 Scatter chart
Most read
5
5
Bar Graph
The bar graph represents data in horizontal or vertical bars. The bar() function is used to create bar graph. It is
most commonly used for 2D data representation. Just have a look at the following code:
import matplotlib.pyplot as mpp
overs=[5,10,15,20]
runs=[30,80,120,200]
mpp.bar(runs,overs,width=30, label='Runs',color='r')
mpp.xlabel('Runs')
mpp.ylabel('Overs')
mpp.title('Match Summary')
mpp.legend()
mpp.show()
Output:
Bar Graph in python 3.8.3
Most read
1
Data Visualization using PyPlot
Read the following quotes:
“Visualization gives you answers to questions you didn’t know you had.” - Ben Schneiderman
“An editorial approach to visualization design requires us to take responsibility to filter out the noise from the
signals, identifying the most valuable, most striking or most relevant dimensions of the subject matter in
question.” - Andy Kirk
“Data visualization doesn’t live in an ethereal dimension, separated from the data. When there’s a large number
of pie-charts in a report or a presentation, there is something wrong in the organization, and it’s not the pie. A
pie chart is a potential symptom of lack of data analysis skills that have to be resolved.” – Jorge Camoes
Quotes Source
Pictures playing an important role in representing data. As we all are aware that pictures giving a more and
more clear understanding of any kind of data or complex problems. Some of the images help to understand the
structure or patterns of data flow and execution.
Before going ahead, If you missed the notes on data frames check out our main page of Informatics
Practices class XII portion.
In this post, we will discuss the following topics:
Basic components of Graph
A graph has the following basic components:
1. Figure or chart area: The entire area covered by the graph is known as a figure. It can be also
considered as a canvas or chart area also.
2. Axis: These are the number of lines generated on the plot. Basically, there are two axis X and Y-axis.
3. Artist: The components like text objects, Line 2D objects, collection objects, etc.
4. Titles: There are few titles involved with your charts such as Chart Title, Axis title, etc.
5. Legends: Legends are the information that represents data with lines or dots.
Matplolib
Python supports a variety of packages to handle data. Matplotlib is also one of the most important packages out
of them. It is a low-level library integrated with Matlab like interface offers few lines of code and draw graphs
or charts. It has modules such as pyplot to draw and create graphs.
Steps how to use Matplotlib
Step 1 Installation of matplotlib
Install matplotlib by following these simple steps:
Step 1: Open cmd from the start menu
Step 2: Type pip install matplotlib
2
Step 2 import module
Import matplotlib.pylot using import command in the following two ways:
1. Without instance
import matplotlib.pyplot
2. With instance
import matplotlib.pyplot as mpp
Step 3 Choose desired plot type (graph type)
In this step, select your desired chart type for plotting. For example, line chart
Step 4 Give proper labels to axis, categories
A graph is made up of two-axis i.e. X and Y-axis. In this step label them as per the need as well as apply proper
labels for categories also.
Step 5 Add data points
The next point is to add data points. Data points depict the point on the plot at a particular place.
Step 6 Add more functionality like colors, sizes etc
To make your graphs more effective and informative use different colors and different sizes.
The common method used to plot a chart is plot().
The Pyplot package provides an interface to plot the graph automatically as per the requirements. You just need
to provide accurate values for axes, categories, labels, title, legend, and data points.
Matplotlib provides the following types of graphs in python:
 Line plot
 Bar graph
 Histogram
 Pie chart
 Scatter chart
3
Creating a Line chart or Plotting lines
To create a line chart following functions are used:
 plot(x,y,color,others): Draw lines as per specified lines
 xlabel("label"): For label to x-axis
 ylabel("label"): For label to y-axis
 title("Title"): For title of the axes
 legend(): For displaying legends
 show() : Display the graph
Now observe the following code:
import matplotlib.pyplot as mpp
mpp.plot(['English','Maths','Hindi'],[88,90,94],'Red')
mpp.xlabel('Subjects')
mpp.ylabel('Marks')
mpp.title('Progress Report Chart')
mpp.show()
Output:
Line plot in Python 3.8.3
4
In the above code, 3 subject marks are plotted on the figure. The navigation toolbar helps to navigate through
the graph. Now observe the following code for plotting multiple lines on the graph.
import matplotlib.pyplot as mpp
o=[5,10,15,20]
r_india=[30,80,120,200]
mpp.plot(o,r_india,'Red')
r_aust=[25,85,100,186]
mpp.plot(o,r_aust,'Yellow')
mpp.xlabel('Runs')
mpp.ylabel('Overs')
mpp.title('Match Summary')
mpp.show()
Output:
Multiline chart using Python 3.8.3
So now you understand how to plot lines on the figure. You can change the color using abbreviations and line
style by using linestyle parameter also. Just do the following changes in above-given code and see the output:
mpp.plot(o,r_india,'m',linestyle=':')
mpp.plot(o,r_aust,'y',linestyle='-.')
5
Bar Graph
The bar graph represents data in horizontal or vertical bars. The bar() function is used to create bar graph. It is
most commonly used for 2D data representation. Just have a look at the following code:
import matplotlib.pyplot as mpp
overs=[5,10,15,20]
runs=[30,80,120,200]
mpp.bar(runs,overs,width=30, label='Runs',color='r')
mpp.xlabel('Runs')
mpp.ylabel('Overs')
mpp.title('Match Summary')
mpp.legend()
mpp.show()
Output:
Bar Graph in python 3.8.3

More Related Content

What's hot (20)

11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
Praveen M Jigajinni
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
Pranav Gupta
 
Recursion CBSE Class 12
Recursion CBSE Class 12Recursion CBSE Class 12
Recursion CBSE Class 12
chinthala Vijaya Kumar
 
Google colab introduction
Google colab   introductionGoogle colab   introduction
Google colab introduction
Saravanakumar viswanathan
 
Python basics
Python basicsPython basics
Python basics
ssuser4e32df
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Edureka!
 
Python
PythonPython
Python
Aashish Jain
 
Python PPT
Python PPTPython PPT
Python PPT
Edureka!
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners
Sujith Kumar
 
5 pen pc technology by divya
5 pen pc technology by divya5 pen pc technology by divya
5 pen pc technology by divya
Divya Baghel
 
5 pen-pc-technology complete ppt
5 pen-pc-technology complete ppt5 pen-pc-technology complete ppt
5 pen-pc-technology complete ppt
atinav242
 
Pytorch
PytorchPytorch
Pytorch
ehsan tr
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
Edureka!
 
Python list
Python listPython list
Python list
Mohammed Sikander
 
ppt on virtual keyboard
ppt on virtual keyboardppt on virtual keyboard
ppt on virtual keyboard
vinaybhaskar15
 
Virtual keyboard
Virtual keyboardVirtual keyboard
Virtual keyboard
siddhantranjan
 
Digital jewellery ppt
Digital jewellery pptDigital jewellery ppt
Digital jewellery ppt
Rithu Pudiyaveedu
 
Function in Python
Function in PythonFunction in Python
Function in Python
Yashdev Hada
 
Python for Data Science
Python for Data SciencePython for Data Science
Python for Data Science
Harri Hämäläinen
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
Praveen M Jigajinni
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
Pranav Gupta
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...
Edureka!
 
Python PPT
Python PPTPython PPT
Python PPT
Edureka!
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners
Sujith Kumar
 
5 pen pc technology by divya
5 pen pc technology by divya5 pen pc technology by divya
5 pen pc technology by divya
Divya Baghel
 
5 pen-pc-technology complete ppt
5 pen-pc-technology complete ppt5 pen-pc-technology complete ppt
5 pen-pc-technology complete ppt
atinav242
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
Edureka!
 
ppt on virtual keyboard
ppt on virtual keyboardppt on virtual keyboard
ppt on virtual keyboard
vinaybhaskar15
 
Function in Python
Function in PythonFunction in Python
Function in Python
Yashdev Hada
 

Similar to Data visualization using py plot part i (20)

Matplotlib yayyyyyyyyyyyyyin Python.pptx
Matplotlib yayyyyyyyyyyyyyin Python.pptxMatplotlib yayyyyyyyyyyyyyin Python.pptx
Matplotlib yayyyyyyyyyyyyyin Python.pptx
AamnaRaza1
 
12-IP.pdf
12-IP.pdf12-IP.pdf
12-IP.pdf
kajalkhorwal106
 
a9bf73_Introduction to Matplotlib01.pptx
a9bf73_Introduction to Matplotlib01.pptxa9bf73_Introduction to Matplotlib01.pptx
a9bf73_Introduction to Matplotlib01.pptx
Rahidkhan10
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
yazad dumasia
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptxUNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
Matplot Lib Practicals artificial intelligence.pptx
Matplot Lib Practicals artificial intelligence.pptxMatplot Lib Practicals artificial intelligence.pptx
Matplot Lib Practicals artificial intelligence.pptx
PianoPianist
 
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvfmatplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
zmulani8
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
ajay_opjs
 
Python chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptxPython chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptx
sonali sonavane
 
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUESUNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
hemalathab24
 
Matplotlib_Presentation jk jdjklskncncsjkk
Matplotlib_Presentation jk jdjklskncncsjkkMatplotlib_Presentation jk jdjklskncncsjkk
Matplotlib_Presentation jk jdjklskncncsjkk
sarfarazkhanwattoo
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
Paras Intotech
 
Python Visualization API Primersubplots
Python Visualization  API PrimersubplotsPython Visualization  API Primersubplots
Python Visualization API Primersubplots
VidhyaB10
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
SharmilaMore5
 
data analytics and visualization CO4_18_Data Types for Plotting.pptx
data analytics and visualization CO4_18_Data Types for Plotting.pptxdata analytics and visualization CO4_18_Data Types for Plotting.pptx
data analytics and visualization CO4_18_Data Types for Plotting.pptx
JAVVAJI VENKATA RAO
 
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYAPYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
Maulik Borsaniya
 
Unit III for data science engineering.pptx
Unit III for data science engineering.pptxUnit III for data science engineering.pptx
Unit III for data science engineering.pptx
rhsingh033
 
matplotlib _
matplotlib                                _matplotlib                                _
matplotlib _
swati463221
 
Matplotlib.pptx for data analysis and visualization
Matplotlib.pptx for data analysis and visualizationMatplotlib.pptx for data analysis and visualization
Matplotlib.pptx for data analysis and visualization
bdike
 
Matplotlib yayyyyyyyyyyyyyin Python.pptx
Matplotlib yayyyyyyyyyyyyyin Python.pptxMatplotlib yayyyyyyyyyyyyyin Python.pptx
Matplotlib yayyyyyyyyyyyyyin Python.pptx
AamnaRaza1
 
a9bf73_Introduction to Matplotlib01.pptx
a9bf73_Introduction to Matplotlib01.pptxa9bf73_Introduction to Matplotlib01.pptx
a9bf73_Introduction to Matplotlib01.pptx
Rahidkhan10
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
yazad dumasia
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
UNIT_4_data visualization.pptx
UNIT_4_data visualization.pptxUNIT_4_data visualization.pptx
UNIT_4_data visualization.pptx
BhagyasriPatel2
 
Matplot Lib Practicals artificial intelligence.pptx
Matplot Lib Practicals artificial intelligence.pptxMatplot Lib Practicals artificial intelligence.pptx
Matplot Lib Practicals artificial intelligence.pptx
PianoPianist
 
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvfmatplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
matplotlib.pptxdsfdsfdsfdsdsfdsdfdsfsdf cvvf
zmulani8
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
ajay_opjs
 
Python chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptxPython chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptx
sonali sonavane
 
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUESUNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
hemalathab24
 
Matplotlib_Presentation jk jdjklskncncsjkk
Matplotlib_Presentation jk jdjklskncncsjkkMatplotlib_Presentation jk jdjklskncncsjkk
Matplotlib_Presentation jk jdjklskncncsjkk
sarfarazkhanwattoo
 
Python Visualization API Primersubplots
Python Visualization  API PrimersubplotsPython Visualization  API Primersubplots
Python Visualization API Primersubplots
VidhyaB10
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
SharmilaMore5
 
data analytics and visualization CO4_18_Data Types for Plotting.pptx
data analytics and visualization CO4_18_Data Types for Plotting.pptxdata analytics and visualization CO4_18_Data Types for Plotting.pptx
data analytics and visualization CO4_18_Data Types for Plotting.pptx
JAVVAJI VENKATA RAO
 
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYAPYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
Maulik Borsaniya
 
Unit III for data science engineering.pptx
Unit III for data science engineering.pptxUnit III for data science engineering.pptx
Unit III for data science engineering.pptx
rhsingh033
 
Matplotlib.pptx for data analysis and visualization
Matplotlib.pptx for data analysis and visualizationMatplotlib.pptx for data analysis and visualization
Matplotlib.pptx for data analysis and visualization
bdike
 
Ad

Recently uploaded (20)

Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptxChalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POSHow to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POSHow to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Ad

Data visualization using py plot part i

  • 1. 1 Data Visualization using PyPlot Read the following quotes: “Visualization gives you answers to questions you didn’t know you had.” - Ben Schneiderman “An editorial approach to visualization design requires us to take responsibility to filter out the noise from the signals, identifying the most valuable, most striking or most relevant dimensions of the subject matter in question.” - Andy Kirk “Data visualization doesn’t live in an ethereal dimension, separated from the data. When there’s a large number of pie-charts in a report or a presentation, there is something wrong in the organization, and it’s not the pie. A pie chart is a potential symptom of lack of data analysis skills that have to be resolved.” – Jorge Camoes Quotes Source Pictures playing an important role in representing data. As we all are aware that pictures giving a more and more clear understanding of any kind of data or complex problems. Some of the images help to understand the structure or patterns of data flow and execution. Before going ahead, If you missed the notes on data frames check out our main page of Informatics Practices class XII portion. In this post, we will discuss the following topics: Basic components of Graph A graph has the following basic components: 1. Figure or chart area: The entire area covered by the graph is known as a figure. It can be also considered as a canvas or chart area also. 2. Axis: These are the number of lines generated on the plot. Basically, there are two axis X and Y-axis. 3. Artist: The components like text objects, Line 2D objects, collection objects, etc. 4. Titles: There are few titles involved with your charts such as Chart Title, Axis title, etc. 5. Legends: Legends are the information that represents data with lines or dots. Matplolib Python supports a variety of packages to handle data. Matplotlib is also one of the most important packages out of them. It is a low-level library integrated with Matlab like interface offers few lines of code and draw graphs or charts. It has modules such as pyplot to draw and create graphs. Steps how to use Matplotlib Step 1 Installation of matplotlib Install matplotlib by following these simple steps: Step 1: Open cmd from the start menu Step 2: Type pip install matplotlib
  • 2. 2 Step 2 import module Import matplotlib.pylot using import command in the following two ways: 1. Without instance import matplotlib.pyplot 2. With instance import matplotlib.pyplot as mpp Step 3 Choose desired plot type (graph type) In this step, select your desired chart type for plotting. For example, line chart Step 4 Give proper labels to axis, categories A graph is made up of two-axis i.e. X and Y-axis. In this step label them as per the need as well as apply proper labels for categories also. Step 5 Add data points The next point is to add data points. Data points depict the point on the plot at a particular place. Step 6 Add more functionality like colors, sizes etc To make your graphs more effective and informative use different colors and different sizes. The common method used to plot a chart is plot(). The Pyplot package provides an interface to plot the graph automatically as per the requirements. You just need to provide accurate values for axes, categories, labels, title, legend, and data points. Matplotlib provides the following types of graphs in python:  Line plot  Bar graph  Histogram  Pie chart  Scatter chart
  • 3. 3 Creating a Line chart or Plotting lines To create a line chart following functions are used:  plot(x,y,color,others): Draw lines as per specified lines  xlabel("label"): For label to x-axis  ylabel("label"): For label to y-axis  title("Title"): For title of the axes  legend(): For displaying legends  show() : Display the graph Now observe the following code: import matplotlib.pyplot as mpp mpp.plot(['English','Maths','Hindi'],[88,90,94],'Red') mpp.xlabel('Subjects') mpp.ylabel('Marks') mpp.title('Progress Report Chart') mpp.show() Output: Line plot in Python 3.8.3
  • 4. 4 In the above code, 3 subject marks are plotted on the figure. The navigation toolbar helps to navigate through the graph. Now observe the following code for plotting multiple lines on the graph. import matplotlib.pyplot as mpp o=[5,10,15,20] r_india=[30,80,120,200] mpp.plot(o,r_india,'Red') r_aust=[25,85,100,186] mpp.plot(o,r_aust,'Yellow') mpp.xlabel('Runs') mpp.ylabel('Overs') mpp.title('Match Summary') mpp.show() Output: Multiline chart using Python 3.8.3 So now you understand how to plot lines on the figure. You can change the color using abbreviations and line style by using linestyle parameter also. Just do the following changes in above-given code and see the output: mpp.plot(o,r_india,'m',linestyle=':') mpp.plot(o,r_aust,'y',linestyle='-.')
  • 5. 5 Bar Graph The bar graph represents data in horizontal or vertical bars. The bar() function is used to create bar graph. It is most commonly used for 2D data representation. Just have a look at the following code: import matplotlib.pyplot as mpp overs=[5,10,15,20] runs=[30,80,120,200] mpp.bar(runs,overs,width=30, label='Runs',color='r') mpp.xlabel('Runs') mpp.ylabel('Overs') mpp.title('Match Summary') mpp.legend() mpp.show() Output: Bar Graph in python 3.8.3