SlideShare a Scribd company logo
Exploring Pylab in
Python with examples
Sarvajanik College of Engineering & Technology
Computer (Shift-1) 8th Semester Group 3 (Morning)
Prepared by:
Name Enrollment No
Dhameyia Vatsalkumar Nareshbhai 140420107012
Shah Dhrashti Paramal 140420107013
Dudhwala Francy Kalpesh 140420107014
Dumasia Yazad Dumasia 140420107015
Prof. Niriali Nanavati
Prof. Rachana Oza
Guided
by
2
Content: A glimpse of what is to come
• Introduction to Pylab
• Introduction to Matplotlib
• Few basic libraries along with Matplotlib
• How to install matplotlib in our computer
• Formatting the Plot
• Few type of basic Plot
• Reference
3
PyLab is actually embedded inside Matplotlib and provides
a Matlab like experience for the user.
It imports portions of Matplotlib and NumPy. Many
examples on the web use it as a simpler MATLAB like
experience, but it is not recommended anymore as it
doesn't nurture understanding of Python itself, thus leaving
you in a limited environment.
Introduction to Pylab
4
Pylab is a module that belongs to the python mathematics library
matplotlib.
Pylab is one kind of “magic function” that can call within ipython or
interactive python. By invoking it, python interpreter will import
matplotlib and numpy modules for accessing their built-in functions.
Pylab combines the numerical module numpy with the graphical
plotting module pyplot.
Pylab was designed with the interactive python interpreter in mind, and
therefore many of its functions are short and require minimal typing.
Introduction to Pylab
5
 Matplotlib is a library for making 2D plots of arrays in Python. Although it
has its origins in emulating the MATLAB graphics commands, it is
independent of MATLAB, and can be used in a Pythonic, object oriented
way.
 Although Matplotlib is written primarily in pure Python, it makes heavy use
of NumPy and other extension code to provide good performance even for
large arrays.
 Matplotlib is designed with the philosophy that you should be able to create
simple plots with just a few commands, or just one! If you want to see a
histogram of your data, you shouldn’t need to instantiate objects, call
methods, set properties, and so on; it should just work.
Introduction to Matplotlib
6
7
Few basic libraries along with Matplotlib
NumPy:
► NumPy, the Numerical Python package, forms much of the underlying numerical
foundation that everything else here relies on.
► Or in other words, it is a library for the Python programming language, adding
support for large, multi-dimensional arrays and matrices, along with a large
collection of high-level mathematical functions to operate on these arrays.
►For use this library , import NumPy as np
► E.g. import numpy as np
print np.log2(8)
returns 3, as 23=8 . For this form, log2(3) will return an error, as log2 is
unknown to Python without the np.
► Or else this would like
from numpy import *
log2(8)
► which returns 3. However, np.log2(3) will no longer work but it not preferable as by
coder.
88
Pyplot:
 Matplotlib is a plotting library for the Python programming language and
its numerical mathematics extension NumPy. It provides an object-
oriented API for embedding plots into applications using general-
purpose GUI toolkits like Tkinter.
 Example of Pyplot :
Few basic libraries along with Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers on Y-axis’)
plt.xlabel('some numbers on X-axis’)
plt.show()
9
How to install matplotlib in windows 10
Setting Path for Python 2.7.13 in windows in order download of matplotlib:
Necessary path
required for in
order download
matplotlib
10
Install matplotlib via command prompt in windows:
Setp2. Install of matplotlib via CMD
Step 1. In order install package in
python we have update your package
manager
11
How to install matplotlib in Ubuntu Linux
 Step 1:Open up a bash shell.
 Step 2:Type in the following command to download and install Matplotlib:
sudo apt-get install python-matplotlib
 Step 3:Type in the administrators password to proceed with the install.
How to install matplotlib in CentOS Linux
►Step 1:Open up a terminal.
►Step 2:Type in the following command to download and install
Matplotlib:
sudo yum install python-matplotlib
►Step 3:It will proceed to the install from internet.
12
Changing the Color of line and style of line:
It is very useful to plot more than one set of data on same axes
and to differentiate between them by using different line &
marker styles and colors .
plylab.plot(X,Y,par)
You can specify the color by inserting 3rd parameter into the
plot() method.
Matplotlib offers a variety of options for color, linestyle and
marker.
Formatting the Plot
13
Color
code
Color
Displayed
r Red
b Blue
g Green
c Cyan
m Magenta
y Yellow
k Black
w White
Marker
code
Marker
Displayed
+ Plus Sign
. Dot
O Circle
* Star
p Pentagon
s Square
x X Character
D Diamond
h Hexagon
^ Triangle
Line style
code
Line Style
Displayed
- Solid Line
-- Dashed
Line
: Dotted
Line
-. Dash-
Dotted
line
None No
Connectin
g Lines
Formatting codes
14
 It is very important to always label the axis of plots to tell the user or viewer
what they are looking at which variable as X- axis and Y-axis.
 Command use in for label in python:
pl.xlabel(‘X-axis variable’)
pl.ylabel(‘Y-axis variable’)
 Your can add title for your plot by using python command :
pl.title(‘Put your title’)
 You can save output of your plot as image:
plt.savefig(“output.png")
 You can also change the x and y range displayed on your plot:
pl.xlim(x_low,x_high)
pl.ylim(y_low,y_high)
Plot and Axis titles and limits
15
1. Line Plot
2. Scatter Plot
3. Histograms Plot
4. Pie Chart
5. Subplot
Few type of basic Plot:
16
Line Plot:
A line plot is used to relate the value of x to particular value y
import numpy as nmp
import pylab as pyl
x=[1,2,3,4,5]
y=[1,8,5,55,66]
pyl.plot(x,y,linestyle="-.",marker="o",color="red")
pyl.title("Line Plot Demo")
pyl.xlabel("X-axis")
pyl.ylabel("Y-axis")
pyl.savefig("line_demo.png")
pyl.show()
import numpy as np
import matplotlib.pyplot as plt
fig, (ax1) = plt.subplots(1)
x = np.linspace(0, 1, 10)
for j in range(10):
ax1.plot(x, x * j)
plt.savefig("one_many.png")
plt.show()
17
Scatter Plot :
A Scatter plot is used the position of each element is scattered.
import numpy as nmp
import pylab as pyl
x=nmp.random.randn(1,100)
y=nmp.random.randn(1,100)
pyl.title("Scatter Plot Demon")
pyl.scatter(x,y,s=20,color="red")
#s denote size of dot
pyl.savefig("scatter_demo.png")
pyl.show()
import numpy as np
import matplotlib.pyplot as plt
x = [0,2,4,6,8,10]
y = [0]*len(x)
s = [20*2**n for n in range(len(x))]
plt.scatter(x,y,s=s,color="green")
plt.savefig("radom_plot_dots.png")
plt.show()
18
Pie chart Plot :
 A pie graph (or pie chart) is a specialized graph used in statistics. The independent variable
is plotted around a circle in either a clockwise direction or a counterclockwise direction. The
dependent variable (usually a percentage) is rendered as an arc whose measure is
proportional to the magnitude of the quantity. The independent variable can attain a finite
number of discrete values. The dependent variable can attain any value from zero to 100
percent.
import matplotlib.pyplot as pyplot
x_list = [10, 12, 50]
label_list = ["Python", "Artificial Intelligence",
"Project"]
pyplot.axis("equal")
pyplot.pie(x_list,labels=label_list,autopct="%1.0f%%")
#autopct show the percentage of each element
pyplot.title("Subject of Final Semester")
pyplot.savefig("pie_demo.png")
pyplot.show()
19
Explode Pie chart Plot :
import numpy as nmp
import pylab as ptl
labels = ["Python", "Artificial Intelligence", "Project"]
sizes=[13,16,70]
colors=["gold","yellowgreen","lightblue"]
explode = (0.1,0.1,0.1)
ptl.axis("equal")
ptl.pie(sizes,explode=explode,labels=labels,colors=
colors,autopct="%1.1f%%",shadow=True,startangle
=110)
ptl.legend(labels,loc="upper left")
ptl.title("Subject of Final Semester")
ptl.savefig("pie_explode_demo.png")
ptl.show()
20
Subplot :
subplot(m,n,p) divides the
current figure into an m-by-n
grid and creates axes in the
position specified by p. The
first subplot is the first column
of the first row, the second
subplot is the second column of
the first row, and so on. If axes
exist in the specified position,
then this command makes the
axes the current axes.
21
Subplot :
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(0)
dt = 0.01
Fs = 1/dt
t = np.arange(0, 10, dt)
nse = np.random.randn(len(t))
r = np.exp(-t/0.05)
cnse = np.convolve(nse, r)*dt
cnse = cnse[:len(t)]
s = 0.1*np.sin(2*np.pi*t) + cnse
plt.subplot(3, 2, 1)
plt.plot(t, s)
plt.title(' Simple demo of spectrum
anaylsis’)
plt.ylabel('Frequency'+'n')
#plt.savefig("spr1.png")
plt.subplot(3, 2, 3)
plt.magnitude_spectrum(s, Fs=Fs)
plt.xlabel('Energy')
plt.ylabel('Frequency'+'n')
#plt.savefig("spr2.png")
plt.subplot(3, 2, 4)
plt.magnitude_spectrum(s, Fs=Fs,
scale='dB')
plt.xlabel('Energy')
plt.ylabel(' ')
#plt.savefig("spr3.png")
plt.subplot(3, 2, 5)
plt.angle_spectrum(s, Fs=Fs)
plt.xlabel('Energy')
plt.ylabel('Frequency'+'n')
#plt.savefig("sp4.png")
plt.subplot(3, 2, 6)
plt.phase_spectrum(s, Fs=Fs)
plt.xlabel('Energy')
plt.ylabel(' ')
plt.savefig("spr_demo.png")
plt.show()
22
23
Reference
https://matplotlib.org
24
Thank You…

More Related Content

What's hot

Introduction to Python and Matplotlib
Introduction to Python and MatplotlibIntroduction to Python and Matplotlib
Introduction to Python and Matplotlib
François Bianco
 
High Performance Python - Marc Garcia
High Performance Python - Marc GarciaHigh Performance Python - Marc Garcia
High Performance Python - Marc Garcia
Marc Garcia
 
NUMPY
NUMPY NUMPY
Python NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaPython NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | Edureka
Edureka!
 
Tensorflow windows installation
Tensorflow windows installationTensorflow windows installation
Tensorflow windows installation
marwa Ayad Mohamed
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
Gabriel Hamilton
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
Pramod Toraskar
 
Tensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi chaTensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi cha
Donghwi Cha
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
kammeyer
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guideArulalan T
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPy
Devashish Kumar
 
Five python libraries should know for machine learning
Five python libraries should know for machine learningFive python libraries should know for machine learning
Five python libraries should know for machine learning
Naveen Davis
 
Intellectual technologies
Intellectual technologiesIntellectual technologies
Intellectual technologies
Polad Saruxanov
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
Tensorflow for Beginners
Tensorflow for BeginnersTensorflow for Beginners
Tensorflow for Beginners
Sam Dias
 
NumPy
NumPyNumPy
Demo1 use numpy
Demo1 use numpyDemo1 use numpy
Demo1 use numpy
Romaric Saounde Tsopnang
 
Deep Learning in theano
Deep Learning in theanoDeep Learning in theano
Deep Learning in theano
Massimo Quadrana
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
Jatin Miglani
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8ecomputernotes
 

What's hot (20)

Introduction to Python and Matplotlib
Introduction to Python and MatplotlibIntroduction to Python and Matplotlib
Introduction to Python and Matplotlib
 
High Performance Python - Marc Garcia
High Performance Python - Marc GarciaHigh Performance Python - Marc Garcia
High Performance Python - Marc Garcia
 
NUMPY
NUMPY NUMPY
NUMPY
 
Python NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaPython NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | Edureka
 
Tensorflow windows installation
Tensorflow windows installationTensorflow windows installation
Tensorflow windows installation
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 
Tensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi chaTensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi cha
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guide
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPy
 
Five python libraries should know for machine learning
Five python libraries should know for machine learningFive python libraries should know for machine learning
Five python libraries should know for machine learning
 
Intellectual technologies
Intellectual technologiesIntellectual technologies
Intellectual technologies
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
 
Tensorflow for Beginners
Tensorflow for BeginnersTensorflow for Beginners
Tensorflow for Beginners
 
NumPy
NumPyNumPy
NumPy
 
Demo1 use numpy
Demo1 use numpyDemo1 use numpy
Demo1 use numpy
 
Deep Learning in theano
Deep Learning in theanoDeep Learning in theano
Deep Learning in theano
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
 

Similar to Introduction to Pylab and Matploitlib.

Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
Dr. Amanpreet Kaur
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
SharmilaMore5
 
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
Python-Libraries,Numpy,Pandas,Matplotlib.pptxPython-Libraries,Numpy,Pandas,Matplotlib.pptx
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
anushya2915
 
Python for Data Science
Python for Data SciencePython for Data Science
Python for Data Science
Panimalar Engineering College
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
Haim Michael
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
aeberspaecher
 
Data visualization using py plot part i
Data visualization using py plot part iData visualization using py plot part i
Data visualization using py plot part i
TutorialAICSIP
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
ajay_opjs
 
UNit-III. part 2.pdf
UNit-III. part 2.pdfUNit-III. part 2.pdf
UNit-III. part 2.pdf
MastiCreation
 
12-IP.pdf
12-IP.pdf12-IP.pdf
12-IP.pdf
kajalkhorwal106
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
Paras Intotech
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
App Ttrainers .com
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Introduction to Machine Learning by MARK
Introduction to Machine Learning by MARKIntroduction to Machine Learning by MARK
Introduction to Machine Learning by MARK
MRKUsafzai0607
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
Dozie Agbo
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
CP-Union
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
Machine learning Experiments report
Machine learning Experiments report Machine learning Experiments report
Machine learning Experiments report
AlmkdadAli
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 

Similar to Introduction to Pylab and Matploitlib. (20)

Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
 
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
Python-Libraries,Numpy,Pandas,Matplotlib.pptxPython-Libraries,Numpy,Pandas,Matplotlib.pptx
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
 
Python for Data Science
Python for Data SciencePython for Data Science
Python for Data Science
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
 
Data visualization using py plot part i
Data visualization using py plot part iData visualization using py plot part i
Data visualization using py plot part i
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
 
UNit-III. part 2.pdf
UNit-III. part 2.pdfUNit-III. part 2.pdf
UNit-III. part 2.pdf
 
12-IP.pdf
12-IP.pdf12-IP.pdf
12-IP.pdf
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Introduction to Machine Learning by MARK
Introduction to Machine Learning by MARKIntroduction to Machine Learning by MARK
Introduction to Machine Learning by MARK
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
Machine learning Experiments report
Machine learning Experiments report Machine learning Experiments report
Machine learning Experiments report
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 

More from yazad dumasia

Schemas for multidimensional databases
Schemas for multidimensional databasesSchemas for multidimensional databases
Schemas for multidimensional databases
yazad dumasia
 
Classification decision tree
Classification  decision treeClassification  decision tree
Classification decision tree
yazad dumasia
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
yazad dumasia
 
Basic economic problem: Inflation
Basic economic problem: InflationBasic economic problem: Inflation
Basic economic problem: Inflation
yazad dumasia
 
Groundwater contamination
Groundwater contaminationGroundwater contamination
Groundwater contamination
yazad dumasia
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
yazad dumasia
 
Cyber crime
Cyber crimeCyber crime
Cyber crime
yazad dumasia
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
yazad dumasia
 

More from yazad dumasia (8)

Schemas for multidimensional databases
Schemas for multidimensional databasesSchemas for multidimensional databases
Schemas for multidimensional databases
 
Classification decision tree
Classification  decision treeClassification  decision tree
Classification decision tree
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
 
Basic economic problem: Inflation
Basic economic problem: InflationBasic economic problem: Inflation
Basic economic problem: Inflation
 
Groundwater contamination
Groundwater contaminationGroundwater contamination
Groundwater contamination
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
Cyber crime
Cyber crimeCyber crime
Cyber crime
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 

Recently uploaded

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 

Recently uploaded (20)

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 

Introduction to Pylab and Matploitlib.

  • 1. Exploring Pylab in Python with examples Sarvajanik College of Engineering & Technology Computer (Shift-1) 8th Semester Group 3 (Morning)
  • 2. Prepared by: Name Enrollment No Dhameyia Vatsalkumar Nareshbhai 140420107012 Shah Dhrashti Paramal 140420107013 Dudhwala Francy Kalpesh 140420107014 Dumasia Yazad Dumasia 140420107015 Prof. Niriali Nanavati Prof. Rachana Oza Guided by 2
  • 3. Content: A glimpse of what is to come • Introduction to Pylab • Introduction to Matplotlib • Few basic libraries along with Matplotlib • How to install matplotlib in our computer • Formatting the Plot • Few type of basic Plot • Reference 3
  • 4. PyLab is actually embedded inside Matplotlib and provides a Matlab like experience for the user. It imports portions of Matplotlib and NumPy. Many examples on the web use it as a simpler MATLAB like experience, but it is not recommended anymore as it doesn't nurture understanding of Python itself, thus leaving you in a limited environment. Introduction to Pylab 4
  • 5. Pylab is a module that belongs to the python mathematics library matplotlib. Pylab is one kind of “magic function” that can call within ipython or interactive python. By invoking it, python interpreter will import matplotlib and numpy modules for accessing their built-in functions. Pylab combines the numerical module numpy with the graphical plotting module pyplot. Pylab was designed with the interactive python interpreter in mind, and therefore many of its functions are short and require minimal typing. Introduction to Pylab 5
  • 6.  Matplotlib is a library for making 2D plots of arrays in Python. Although it has its origins in emulating the MATLAB graphics commands, it is independent of MATLAB, and can be used in a Pythonic, object oriented way.  Although Matplotlib is written primarily in pure Python, it makes heavy use of NumPy and other extension code to provide good performance even for large arrays.  Matplotlib is designed with the philosophy that you should be able to create simple plots with just a few commands, or just one! If you want to see a histogram of your data, you shouldn’t need to instantiate objects, call methods, set properties, and so on; it should just work. Introduction to Matplotlib 6
  • 7. 7 Few basic libraries along with Matplotlib NumPy: ► NumPy, the Numerical Python package, forms much of the underlying numerical foundation that everything else here relies on. ► Or in other words, it is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. ►For use this library , import NumPy as np ► E.g. import numpy as np print np.log2(8) returns 3, as 23=8 . For this form, log2(3) will return an error, as log2 is unknown to Python without the np. ► Or else this would like from numpy import * log2(8) ► which returns 3. However, np.log2(3) will no longer work but it not preferable as by coder.
  • 8. 88 Pyplot:  Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. It provides an object- oriented API for embedding plots into applications using general- purpose GUI toolkits like Tkinter.  Example of Pyplot : Few basic libraries along with Matplotlib import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers on Y-axis’) plt.xlabel('some numbers on X-axis’) plt.show()
  • 9. 9 How to install matplotlib in windows 10 Setting Path for Python 2.7.13 in windows in order download of matplotlib: Necessary path required for in order download matplotlib
  • 10. 10 Install matplotlib via command prompt in windows: Setp2. Install of matplotlib via CMD Step 1. In order install package in python we have update your package manager
  • 11. 11 How to install matplotlib in Ubuntu Linux  Step 1:Open up a bash shell.  Step 2:Type in the following command to download and install Matplotlib: sudo apt-get install python-matplotlib  Step 3:Type in the administrators password to proceed with the install. How to install matplotlib in CentOS Linux ►Step 1:Open up a terminal. ►Step 2:Type in the following command to download and install Matplotlib: sudo yum install python-matplotlib ►Step 3:It will proceed to the install from internet.
  • 12. 12 Changing the Color of line and style of line: It is very useful to plot more than one set of data on same axes and to differentiate between them by using different line & marker styles and colors . plylab.plot(X,Y,par) You can specify the color by inserting 3rd parameter into the plot() method. Matplotlib offers a variety of options for color, linestyle and marker. Formatting the Plot
  • 13. 13 Color code Color Displayed r Red b Blue g Green c Cyan m Magenta y Yellow k Black w White Marker code Marker Displayed + Plus Sign . Dot O Circle * Star p Pentagon s Square x X Character D Diamond h Hexagon ^ Triangle Line style code Line Style Displayed - Solid Line -- Dashed Line : Dotted Line -. Dash- Dotted line None No Connectin g Lines Formatting codes
  • 14. 14  It is very important to always label the axis of plots to tell the user or viewer what they are looking at which variable as X- axis and Y-axis.  Command use in for label in python: pl.xlabel(‘X-axis variable’) pl.ylabel(‘Y-axis variable’)  Your can add title for your plot by using python command : pl.title(‘Put your title’)  You can save output of your plot as image: plt.savefig(“output.png")  You can also change the x and y range displayed on your plot: pl.xlim(x_low,x_high) pl.ylim(y_low,y_high) Plot and Axis titles and limits
  • 15. 15 1. Line Plot 2. Scatter Plot 3. Histograms Plot 4. Pie Chart 5. Subplot Few type of basic Plot:
  • 16. 16 Line Plot: A line plot is used to relate the value of x to particular value y import numpy as nmp import pylab as pyl x=[1,2,3,4,5] y=[1,8,5,55,66] pyl.plot(x,y,linestyle="-.",marker="o",color="red") pyl.title("Line Plot Demo") pyl.xlabel("X-axis") pyl.ylabel("Y-axis") pyl.savefig("line_demo.png") pyl.show() import numpy as np import matplotlib.pyplot as plt fig, (ax1) = plt.subplots(1) x = np.linspace(0, 1, 10) for j in range(10): ax1.plot(x, x * j) plt.savefig("one_many.png") plt.show()
  • 17. 17 Scatter Plot : A Scatter plot is used the position of each element is scattered. import numpy as nmp import pylab as pyl x=nmp.random.randn(1,100) y=nmp.random.randn(1,100) pyl.title("Scatter Plot Demon") pyl.scatter(x,y,s=20,color="red") #s denote size of dot pyl.savefig("scatter_demo.png") pyl.show() import numpy as np import matplotlib.pyplot as plt x = [0,2,4,6,8,10] y = [0]*len(x) s = [20*2**n for n in range(len(x))] plt.scatter(x,y,s=s,color="green") plt.savefig("radom_plot_dots.png") plt.show()
  • 18. 18 Pie chart Plot :  A pie graph (or pie chart) is a specialized graph used in statistics. The independent variable is plotted around a circle in either a clockwise direction or a counterclockwise direction. The dependent variable (usually a percentage) is rendered as an arc whose measure is proportional to the magnitude of the quantity. The independent variable can attain a finite number of discrete values. The dependent variable can attain any value from zero to 100 percent. import matplotlib.pyplot as pyplot x_list = [10, 12, 50] label_list = ["Python", "Artificial Intelligence", "Project"] pyplot.axis("equal") pyplot.pie(x_list,labels=label_list,autopct="%1.0f%%") #autopct show the percentage of each element pyplot.title("Subject of Final Semester") pyplot.savefig("pie_demo.png") pyplot.show()
  • 19. 19 Explode Pie chart Plot : import numpy as nmp import pylab as ptl labels = ["Python", "Artificial Intelligence", "Project"] sizes=[13,16,70] colors=["gold","yellowgreen","lightblue"] explode = (0.1,0.1,0.1) ptl.axis("equal") ptl.pie(sizes,explode=explode,labels=labels,colors= colors,autopct="%1.1f%%",shadow=True,startangle =110) ptl.legend(labels,loc="upper left") ptl.title("Subject of Final Semester") ptl.savefig("pie_explode_demo.png") ptl.show()
  • 20. 20 Subplot : subplot(m,n,p) divides the current figure into an m-by-n grid and creates axes in the position specified by p. The first subplot is the first column of the first row, the second subplot is the second column of the first row, and so on. If axes exist in the specified position, then this command makes the axes the current axes.
  • 21. 21 Subplot : import matplotlib.pyplot as plt import numpy as np np.random.seed(0) dt = 0.01 Fs = 1/dt t = np.arange(0, 10, dt) nse = np.random.randn(len(t)) r = np.exp(-t/0.05) cnse = np.convolve(nse, r)*dt cnse = cnse[:len(t)] s = 0.1*np.sin(2*np.pi*t) + cnse plt.subplot(3, 2, 1) plt.plot(t, s) plt.title(' Simple demo of spectrum anaylsis’) plt.ylabel('Frequency'+'n') #plt.savefig("spr1.png") plt.subplot(3, 2, 3) plt.magnitude_spectrum(s, Fs=Fs) plt.xlabel('Energy') plt.ylabel('Frequency'+'n') #plt.savefig("spr2.png") plt.subplot(3, 2, 4) plt.magnitude_spectrum(s, Fs=Fs, scale='dB') plt.xlabel('Energy') plt.ylabel(' ') #plt.savefig("spr3.png") plt.subplot(3, 2, 5) plt.angle_spectrum(s, Fs=Fs) plt.xlabel('Energy') plt.ylabel('Frequency'+'n') #plt.savefig("sp4.png") plt.subplot(3, 2, 6) plt.phase_spectrum(s, Fs=Fs) plt.xlabel('Energy') plt.ylabel(' ') plt.savefig("spr_demo.png") plt.show()
  • 22. 22