[Go to site: main page, start]

0% found this document useful (0 votes)
71 views17 pages

Matplotlib Python Visualization Guide

This document provides an overview of Python Matplotlib for data visualization. It discusses why data visualization is useful, defines data visualization, and introduces Matplotlib as a Python package for 2D graphics. Various plot types are described such as bar graphs, histograms, scatter plots, pie charts, and area plots. Code examples are given to demonstrate generating simple and customized plots, including adding titles, labels, styles. Multiple plots are also demonstrated.

Uploaded by

kuldeep yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views17 pages

Matplotlib Python Visualization Guide

This document provides an overview of Python Matplotlib for data visualization. It discusses why data visualization is useful, defines data visualization, and introduces Matplotlib as a Python package for 2D graphics. Various plot types are described such as bar graphs, histograms, scatter plots, pie charts, and area plots. Code examples are given to demonstrate generating simple and customized plots, including adding titles, labels, styles. Multiple plots are also demonstrated.

Uploaded by

kuldeep yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Matplotlib Tutorial:-

 Why Data Visualization?


 What is Data Visualization?
 What is Matplotlib?
 Types Of Plots
 Getting Started

[Link] Data Visualizaton?:-


Human brain can process
information easily when it is in pictorial or
graphical form.
Data visualization allows us to quickly
interpret the data and adjust different
variables to see their effect.
[Link] is Data Visualization?
Data visualization is the presentation of
data in a pictorial or graphical format.

V i
s u
a l
iz A
e n
a l
D o c y
u m s
e n t e
I n s i
g h t

[Link] is Matplotlib?
Matplotlib is a Python package used for 2D
graphics.
[Link] of Plots:-
[Link] Graph
[Link]
[Link] Plot
[Link] Plot
[Link] Bin Plot
[Link] Plot

[Link] Started:-
Here's some asic code to generate one of the
most simple graph.
Example:-
from matplotlib import pyplot as plt
#Plotting to our canvas
[Link]([1,2,3],[4,5,1])
#Showing what we plotted
[Link]()
Output:-

Let's add title and labels to our graph:-


Example:-
from matplotlib import pyplot as plt
x=[5,3,6]
y=[3,5,2]
[Link](x,y)
[Link]("Information")
[Link]("Y-Axis")
[Link]("X-Axis")
[Link]()
Adding Style To Our Graph:-
from matplotlib import pyplot as plt
from matplotlib import style
[Link]("ggplot")

x=[5,3,2]
y=[4,2,5]
x2=[4,3,7]
y2=[6,7,9]

[Link](x,y,'g',label='line one',linewidth=5)
[Link](x2,y2,'c',label='line two',linewidth=5)

[Link]('Epic Info')
[Link]("Y-Axis")
[Link]("X-Axis")
[Link]()
[Link](True,color='k')
[Link]()
Bar Graph:-

import [Link] as plt

[Link]([3,2,4,5],[6,3,2,6],label="Example
One")
[Link]([4,2,5,6],[9,0,8,7],label="Example
two",color='g')

[Link]()
[Link]('bar number')
[Link]('bar height')

[Link]('My plot yo!')


[Link]()
Histogram:-
import [Link] as plt
population_ages=
[22,33,44,33,44,55,34,64,54,66,77,55,34,54,64,
64,34]
bins=[0,1,20,30,40,50,60,70,80]
[Link](population_ages,bins,histtype='bar',rwi
dth=0.8)
[Link]('x')
[Link]('y')
[Link]('Histogram')
[Link]()
[Link]()
Scatter Plot:-
Example:-
import [Link] as plt
x=[2,1,3,5,6,4,6,7]
y=[4,3,5,6,8,9,8,5]
[Link](x,y,label='skitscat',color='k',s=25,m
arker="0")
[Link]('x')
[Link]('y')
[Link]('Scatter Plot')
[Link]()
[Link]()
Stack Plot(Area Graph):-
import [Link] as plt
days=[1,2,3,4,5]

sleeping=[7,8,8,4,3]
eating=[4,3,5,2,6]
working=[4,6,3,1,4]
playing=[4,6,3,7,8]
[Link]([],
[],color='m',label='Sleeping',linewidth=5)
[Link]([],
[],color='c',label='Eating',linewidth=5)
[Link]([],
[],color='c',label='Working',linewidth=5)
[Link]([],
[],color='c',label='Playing',linewidth=5)
[Link](days,sleeping,eating,working,playi
ng,colors=['m','c','r','k']
[Link]('x')
[Link]('y')
[Link]('Area Plot')
[Link]()
[Link]()
Pie Chart:-
import [Link] as plt
slices=[7,2,2,13]
activities=['Sleeping','Eating','Working','Playin
g']
cols=['c','m','r','b']
[Link](slices,labels=activities,colors=cols,start
angle=90,shadow=True,explode=(0,0.1,0,0),au
topct='%1.1f%%)

[Link]('Pie Plot')
[Link]()

Working With Multiple Plots:-


import numpy as np
import [Link] as plt
def f(t):
return [Link](-t)*[Link](2*[Link]*t)
t1=[Link](0.0,5.0,0.1)
t2=[Link](0.0,5.0,0.02)
[Link](211)
[Link](t1,f(t1),'bo',t2,f(t2))
[Link](212)
[Link](t2,[Link](2*[Link]*t2))
[Link]()

You might also like