SlideShare a Scribd company logo
Algorithmic Efficiency
Intro, Complexity
Finding Complexities
Best, Worst & Average Cases
-> By Apni Kaksha <-
Data
Data is one of the most valuable things today.
All Big companies stores data, which helps in diagnosis, focused services
and many more.
It basically means graphical or visual representation of data & statistics using
elements like charts, graphs and maps,etc.
We can see patterns, trends, relations, etc. in the data.
Data Visualization
Library
It provides many interfaces & functionality for 2D-graphics in various forms.
Basically, it’s a high quality plotting library of python.
PyPlot is such a module in Matplotlib.
PyPlot
Matplotlib comes pre-installed with anaconda.
To run every command we need to write :
matplotlib.pyplot.<command>
Let’s better do :
import matplotlib.pyplot as pl
pl.plot(<x>,<y>)
Shorter way
Numpy
Numpy is a module of python that offers functions for fast mathematical
computation on arrays.
Arrays is a named group of homogeneous elements.
It’s very similar to lists.
All elements are of same datatype.
Functionality is different. .
Creating Array
import numpy as np
L=[1,2,3,4]
a=np.array(L) makes ‘a’ array from List ‘L’.
print( type(a) ) numpy.ndarray
print(a.shape ) (1,)
print(a.itemsize ) 4
print(a.dtype) dtype(‘int32’)
Creating Arrays
import numpy as np
a=np.arange(<start>, <stop>, <step>, <dtype>)
a=np.arange( 1,9,3,np.float32 )
a=np.linespace(<start>,<stop>,<number of values to be generated>)
will generate elements at equal intervals.
a=np.arange( 1,9,2 )
ends at 8
16. Data VIsualization using PyPlot.pdf
import numpy as np
import matplotlib.pyplot as pl
a=np.linspace(1,5,6)
b=np.log(a)
pl.plot(a,b)
pl.xlabel(‘This shows on x axis’)
pl.ylabel(‘This shows on y axis’)
pl.show( )
Plotting using numpy
ends at 5
pl.plot(a-1, b-1, 'b')
pl.plot(a, b, 'r')
pl.plot(a+1, b+1, linewidth=2, linestyle='dashed',
marker='d', markersize=4, markeredgecolor= 'red' )
pl.plot(a+2, b+2, 'bd', linestyle = 'dashdot')
Changing style
Blue & Diamond
16. Data VIsualization using PyPlot.pdf
Charts
BAR CHART PIE CHART LINE CHART
Bar Chart
import matplotlib.pyplot as pl
a=[1,2,3,4,5]
b=[1,4,9,16,25]
pl.bar(a,b)
pl.xlabel(‘N)
pl.ylabel(‘N*N’)
pl.show( )
Default width of bars : 0.8 units
Styling bars
a=[‘Grapes’, ‘Banana’, ‘Apple’, ‘Guava’]
plt.bar(a,b,width = [0.2, 0.5, 0.3, 0.8] )
plt.bar(a,b,color = [‘g’, ‘r’, ‘b’, ‘black’] )
Color & width are applied in left to right order, but the bars are plotted in
sorted order.
16. Data VIsualization using PyPlot.pdf
Styling bars
V =[[5,25,45,20], [4,23,49,17], [6,22,47,19]]
X=np.arange(4)
plt.bar(X, V[0], color=‘b’, width=0.25,label=‘a’)
plt.bar(X+0.25, V[1], color=‘g’, width=0.25,label=‘b’)
plt.bar(X+0.50, V[2], color=‘r’, width=0.25,label=‘c’)
plt.legend(loc='upper left')
Color & width are applied in left to right order, but the bars are plotted in
sorted order.
Horizontal Bar Chart
import matplotlib.pyplot as plt
a=[‘Grapes’, ‘Banana’, ‘Apple’, ‘Guava’]
x=[4,1,2,5]
plt.barh(a, x)
Pie Chart
C=[4,1,8,9]
D=[A1, B1, A2, B2]
plt.axis(‘equal’)
plt.pie(C,labels=D)
Colors may differ. For circular shape.
CLR=[‘green’, ‘blue’, ‘red’, ‘yellow’]
E=[0,0,0.1,0.15]
pl.pie(C, colors=CLR, autopct=‘%2.2f%%’, explode=E)
Styling Pie Charts
Colors may differ.
Styling Pie Chart
C=[4,1,8,9]
D=[A1, B1, A2, B2]
plt.pie(C,labels=D, autopct= ‘%1.1f%%’)
40.9%
18.2%
4.5%
36.4%
Colors may differ.
‘%[FLAG][WIDTH] . [PRECISION]type’
‘%[FLAG][WIDTH] . [PRECISION]type’
It’s a special string which defines the structure of a string.
WIDTH specifies the min. number of characters in the string.
PRECISION is the number of digits till which rounding off takes place after decimal.
type specifies the datatype. Single % specifies it’s a special string,
That’s why we use %%.
‘%3d’ - 24 = _24
‘%05i’ - 24 = 00024
‘%03d%%’ - 24 = 024%
‘%6.1f’ - 24.2 = _24.20
‘%3.3f%%’ - 24.2 = 24.200%
Customizing Chart
plt.title(‘Student’s data’)
X= [0,1,2,3]
Y= [5,25,45,20]
plt.xlim(3.5,-0.5)
plt.ylim(-50,50)
plt.title(‘Student’s data’)
plt.plot(X,Y)
Customizing Chart
plt.title(‘Student’s data’)
X= [0,1,2,3]
Y= [5,25,45,20]
plt.xticks([0,1,2,3],[‘a’, ‘b’, ‘c’, ‘d’])
plt.bar(X,Y)
plt.title(‘Student’s data’)
16. Data VIsualization using PyPlot.pdf

More Related Content

PPTX
UNIT_4_data visualization.pptx
PPTX
Python chart plotting using Matplotlib.pptx
PPTX
Matplotlib.pptx
PDF
Data visualization pyplot
PPTX
matplotlib _
PPTX
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PPTX
Matplotlib_Presentation jk jdjklskncncsjkk
PDF
Chapter3_Visualizations2.pdf
UNIT_4_data visualization.pptx
Python chart plotting using Matplotlib.pptx
Matplotlib.pptx
Data visualization pyplot
matplotlib _
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
Matplotlib_Presentation jk jdjklskncncsjkk
Chapter3_Visualizations2.pdf

Similar to 16. Data VIsualization using PyPlot.pdf (20)

PPTX
Matplot Lib Practicals artificial intelligence.pptx
DOCX
Data visualization using py plot part i
PPTX
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
PPTX
1_ Introduction Python.pptx python is a data
PPTX
Data Visualization using different Python libraries .pptx
PPTX
Introduction to matplotlib
PPTX
Introduction to Pylab and Matploitlib.
PPTX
Data Visualization using different python libraries.pptx
PPTX
Presentation on the basic of numpy and Pandas
PPTX
DATA ANALYSIS AND VISUALISATION using python
PPTX
Matplotlib - Python Plotting Library Description
PPTX
Python_Matplotlib_13. _Slides.pptx
PPTX
Python Pyplot Class XII
PPTX
Matplotlib yayyyyyyyyyyyyyin Python.pptx
PDF
12-IP.pdf
PPTX
a9bf73_Introduction to Matplotlib01.pptx
PPTX
CLO4 - Week13 data analysiss python.pptx
PPTX
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
PDF
Introduction to Data Visualization,Matplotlib.pdf
PPTX
iPython
Matplot Lib Practicals artificial intelligence.pptx
Data visualization using py plot part i
DA_THEORY_PPT DA_THEORY_PPT DA_THEORY_PPT
1_ Introduction Python.pptx python is a data
Data Visualization using different Python libraries .pptx
Introduction to matplotlib
Introduction to Pylab and Matploitlib.
Data Visualization using different python libraries.pptx
Presentation on the basic of numpy and Pandas
DATA ANALYSIS AND VISUALISATION using python
Matplotlib - Python Plotting Library Description
Python_Matplotlib_13. _Slides.pptx
Python Pyplot Class XII
Matplotlib yayyyyyyyyyyyyyin Python.pptx
12-IP.pdf
a9bf73_Introduction to Matplotlib01.pptx
CLO4 - Week13 data analysiss python.pptx
UNIT-5-II IT-DATA VISUALIZATION TECHNIQUES
Introduction to Data Visualization,Matplotlib.pdf
iPython
Ad

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Pre independence Education in Inndia.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Classroom Observation Tools for Teachers
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Business Ethics Teaching Materials for college
Pharmacology of Heart Failure /Pharmacotherapy of CHF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pre independence Education in Inndia.pdf
TR - Agricultural Crops Production NC III.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
RMMM.pdf make it easy to upload and study
Cell Types and Its function , kingdom of life
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Insiders guide to clinical Medicine.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Classroom Observation Tools for Teachers
Supply Chain Operations Speaking Notes -ICLT Program
Business Ethics Teaching Materials for college
Ad

16. Data VIsualization using PyPlot.pdf

  • 1. Algorithmic Efficiency Intro, Complexity Finding Complexities Best, Worst & Average Cases -> By Apni Kaksha <-
  • 2. Data Data is one of the most valuable things today. All Big companies stores data, which helps in diagnosis, focused services and many more.
  • 3. It basically means graphical or visual representation of data & statistics using elements like charts, graphs and maps,etc. We can see patterns, trends, relations, etc. in the data. Data Visualization
  • 4. Library It provides many interfaces & functionality for 2D-graphics in various forms. Basically, it’s a high quality plotting library of python. PyPlot is such a module in Matplotlib.
  • 5. PyPlot Matplotlib comes pre-installed with anaconda. To run every command we need to write : matplotlib.pyplot.<command> Let’s better do : import matplotlib.pyplot as pl pl.plot(<x>,<y>) Shorter way
  • 6. Numpy Numpy is a module of python that offers functions for fast mathematical computation on arrays. Arrays is a named group of homogeneous elements. It’s very similar to lists. All elements are of same datatype. Functionality is different. .
  • 7. Creating Array import numpy as np L=[1,2,3,4] a=np.array(L) makes ‘a’ array from List ‘L’. print( type(a) ) numpy.ndarray print(a.shape ) (1,) print(a.itemsize ) 4 print(a.dtype) dtype(‘int32’)
  • 8. Creating Arrays import numpy as np a=np.arange(<start>, <stop>, <step>, <dtype>) a=np.arange( 1,9,3,np.float32 ) a=np.linespace(<start>,<stop>,<number of values to be generated>) will generate elements at equal intervals. a=np.arange( 1,9,2 ) ends at 8
  • 10. import numpy as np import matplotlib.pyplot as pl a=np.linspace(1,5,6) b=np.log(a) pl.plot(a,b) pl.xlabel(‘This shows on x axis’) pl.ylabel(‘This shows on y axis’) pl.show( ) Plotting using numpy ends at 5
  • 11. pl.plot(a-1, b-1, 'b') pl.plot(a, b, 'r') pl.plot(a+1, b+1, linewidth=2, linestyle='dashed', marker='d', markersize=4, markeredgecolor= 'red' ) pl.plot(a+2, b+2, 'bd', linestyle = 'dashdot') Changing style Blue & Diamond
  • 13. Charts BAR CHART PIE CHART LINE CHART
  • 14. Bar Chart import matplotlib.pyplot as pl a=[1,2,3,4,5] b=[1,4,9,16,25] pl.bar(a,b) pl.xlabel(‘N) pl.ylabel(‘N*N’) pl.show( ) Default width of bars : 0.8 units
  • 15. Styling bars a=[‘Grapes’, ‘Banana’, ‘Apple’, ‘Guava’] plt.bar(a,b,width = [0.2, 0.5, 0.3, 0.8] ) plt.bar(a,b,color = [‘g’, ‘r’, ‘b’, ‘black’] ) Color & width are applied in left to right order, but the bars are plotted in sorted order.
  • 17. Styling bars V =[[5,25,45,20], [4,23,49,17], [6,22,47,19]] X=np.arange(4) plt.bar(X, V[0], color=‘b’, width=0.25,label=‘a’) plt.bar(X+0.25, V[1], color=‘g’, width=0.25,label=‘b’) plt.bar(X+0.50, V[2], color=‘r’, width=0.25,label=‘c’) plt.legend(loc='upper left') Color & width are applied in left to right order, but the bars are plotted in sorted order.
  • 18. Horizontal Bar Chart import matplotlib.pyplot as plt a=[‘Grapes’, ‘Banana’, ‘Apple’, ‘Guava’] x=[4,1,2,5] plt.barh(a, x)
  • 19. Pie Chart C=[4,1,8,9] D=[A1, B1, A2, B2] plt.axis(‘equal’) plt.pie(C,labels=D) Colors may differ. For circular shape.
  • 20. CLR=[‘green’, ‘blue’, ‘red’, ‘yellow’] E=[0,0,0.1,0.15] pl.pie(C, colors=CLR, autopct=‘%2.2f%%’, explode=E) Styling Pie Charts Colors may differ.
  • 21. Styling Pie Chart C=[4,1,8,9] D=[A1, B1, A2, B2] plt.pie(C,labels=D, autopct= ‘%1.1f%%’) 40.9% 18.2% 4.5% 36.4% Colors may differ. ‘%[FLAG][WIDTH] . [PRECISION]type’
  • 22. ‘%[FLAG][WIDTH] . [PRECISION]type’ It’s a special string which defines the structure of a string. WIDTH specifies the min. number of characters in the string. PRECISION is the number of digits till which rounding off takes place after decimal. type specifies the datatype. Single % specifies it’s a special string, That’s why we use %%.
  • 23. ‘%3d’ - 24 = _24 ‘%05i’ - 24 = 00024 ‘%03d%%’ - 24 = 024% ‘%6.1f’ - 24.2 = _24.20 ‘%3.3f%%’ - 24.2 = 24.200%
  • 24. Customizing Chart plt.title(‘Student’s data’) X= [0,1,2,3] Y= [5,25,45,20] plt.xlim(3.5,-0.5) plt.ylim(-50,50) plt.title(‘Student’s data’) plt.plot(X,Y)
  • 25. Customizing Chart plt.title(‘Student’s data’) X= [0,1,2,3] Y= [5,25,45,20] plt.xticks([0,1,2,3],[‘a’, ‘b’, ‘c’, ‘d’]) plt.bar(X,Y) plt.title(‘Student’s data’)