A tutorial Devert Alexandre
UNIVERSITY OF SCIENCE AND TECHNOLOGY OF CHINA
SCHOOL OF SOFTWARE ENGINEERING OF USTC
Matplotlib
A tutorial
Devert Alexandre
School of Software Engineering of USTC
30 November 2012 -- Slide 1/44
UNIVERSITY OF SCIENCE AND TECHNOLOGY OF CHINA
Table of Contents
1 First steps 2 Curve plots 3 Scatter plots 4 Boxplots 5 Histograms 6 Usage example
SCHOOL OF SOFTWARE ENGINEERING OF USTC
Devert Alexandre (School of Software Engineering of USTC) -- Matplotlib -- Slide 2/44
UNIVERSITY OF SCIENCE AND TECHNOLOGY OF CHINA
Curve plot
SCHOOL OF SOFTWARE ENGINEERING OF USTC
Let's plot a curve
import math import matplotlib . pyplot as plt
# Generate a sinusoid nbSamples = 256 xRange = (-math . p i , math . p i )
x, y = [] , [] for n in xrange ( nbSamples ):
k = (n + 0.5) / nbSamples x . append ( xRange [ 0 ] + ( xRange [ 1 ] - xRange [ 0 ] ) k) y . append ( math . s i n ( x [ -1]))
# Plot the sinusoid plt . plot (x , y) p l t . show ()
Devert Alexandre (School of Software Engineering of USTC) -- Matplotlib -- Slide 3/44
UNIVERSITY OF SCIENCE AND TECHNOLOGY OF CHINA
Curve plot
This will show you something like this
SCHOOL OF SOFTWARE ENGINEERING OF USTC
1.0
0.5
0.0
0.5
1.0 4
3
2
10
1
2
3
4
Devert Alexandre (School of Software Engineering of USTC) -- Matplotlib -- Slide 4/44
UNIVERSITY OF SCIENCE AND TECHNOLOGY OF CHINA
numpy
matplotlib can work with numpy arrays
SCHOOL OF SOFTWARE ENGINEERING OF USTC
import math import numpy import matplotlib . pyplot as plt
# Generate a sinusoid nbSamples = 256 xRange = (-math . p i , math . p i )
x , y = numpy . z e r o s ( nbSamples ) , numpy . z e r o s ( nbSamples ) for n in xrange ( nbSamples ):
k = (n + 0.5) / nbSamples x [ n ] = xRange [ 0 ] + ( xRange [ 1 ] - xRange [ 0 ] ) k y [ n ] = math . s i n ( x [ n ] )
# Plot the sinusoid plt . plot (x , y) p l t . show ()
numpy provides a lot of function and is efficient
Devert Alexandre (School of Software Engineering of USTC) -- Matplotlib -- Slide 5/44
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- computing for data science and statistics stat679
- matplotlib tutorialspoint
- lab plotting with matplotlib
- cme193 introductiontoscientificpython lecture5 numpy
- chapter plotting data using 4 matplotlib
- python axis size
- lab 3 plotting with matplotlib and mayavi
- basic plots scales tick locators animation quick start
- a tutorial devert alexandre
- 5 introduction to matplotlib
Related searches
- free excel tutorial download pdf
- printable excel tutorial in pdf
- microsoft excel tutorial pdf download
- ms excel 2013 tutorial pdf
- free basic excel tutorial pdf
- excel 2016 tutorial pdf download
- free microsoft excel tutorial pdf
- excel 2016 tutorial pdf
- excel beginner tutorial pdf
- excel tutorial pdf 2018
- java collections tutorial with examples
- salesforce lightning tutorial for beginners