Matplotlib Quick Reference
Matplotlib Quick Reference
Fixed x-error and variable y-error
12
Matti Pastell, University of Helsinki.
1.0
10
8
0.5
6
Import pylab
4
from pylab import *
0.0
2
0
Line plots
22
x = linspace(0, 2*pi, 100)
y = sin(x)
y2 = cos(x)
plot(x, y)
plot(x, y2, ¡¯og¡¯)
title(¡¯sin(x) and cos(x)¡¯)
xlabel(¡¯x¡¯)
ylabel(¡¯f(x)¡¯)
legend([¡¯sin(x)¡¯, ¡¯cos(x)¡¯], loc = 3)
0
2
4
6
8
10
Bar plot
0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
0
1
2
3
4
Histogram
y = [9, 12, 7]
errors = [1.3, 0.9, 2]
x = arange(len(y))
bar(x, y, yerr=errors, ecolor="red",
capsize=10)
x = randn(1000)
hist(x, bins=20)
14
sin(x) and cos(x)
1.0
12
160
10
140
8
120
6
100
4
80
f(x)
0.5
0.0
1.00
60
2
0.5
sin(x)
cos(x)
1
00.0
2
3
x
4
5
6
40
0.5
1.0
1.5
2.0
2.5
3.0
7
Scatter plot
x = arange(10)
y = x + randn(len(x))
y2 = x + randn(len(x))
scatter(x, y, s=100, alpha=0.7)
scatter(x, y2, s=100, marker="d", color="red")
Errorbars
x = arange(0.1, 4, 0.5)
y = exp(-x)
y_error = 0.1 + 0.2*np.sqrt(x)
x_error = 0.1
errorbar(x, y, xerr = x_error,
yerr = y_error, fmt=¡¯o¡¯, ecolor="red")
title(¡¯Fixed x-error and variable y-error¡¯)
20
04
3
2
1
Boxplot
x = randn(100, 5)
boxplot(x)
2
2
1
1
0
0
¦ÒXY = 0.5
0.200
0.175
Y
0.150
1
1
2
2
0.125
0.100
0.075
0.050
1
2
4
3
33
5
Stem plot
1
2
1
0
X
2
0.000
3
Surface plot
x = range(10)
y = rand(10)
stem(x, y)
1.0
from mpl_toolkits.mplot3d import Axes3D
fig = figure()
ax = fig.add_subplot(111, projection=¡¯3d¡¯)
ax.plot_surface(X, Y, Z, cmap="jet")
sin(0.125n ¡¤x2 )
3
0.025
x = arange(0, 2*pi, 0.2)
y = sin(x)
stem(x,y)
axis([0, 2*pi, -1.2, 1.2])
xlabel(¡¯x¡¯)
ylabel(¡¯sinx(x)¡¯)
subplot(223)
y = randn(1000)
hist(y)
xlabel(¡¯bin¡¯)
ylabel(¡¯count¡¯)
subplot(224)
boxplot(y)
ylabel(¡¯y¡¯)
0.0
0.20
0.6
0.15
0.10
0.4
0.05
0.2
3
0.00
1
2
3
4
5
6
7
8
9
2
1
0
1
2
3
3
2
1
0
1
2
0.00
3
count
200
0.8
0.5
0.5
1.00.0
250
1.0
1.0
0.5
sinx(x)
3
150
100
50
03
0.0
0.5
1.0
0.2 0.4 0.6 0.8 1.0 0
x
4
3
2
1
0
1
2
2 1 0 1 2 3 4 3
bin
1
2
3
x
4
5
6
y
3
1
Links
? Matplotlib tutorial:
?rougier/teaching/matplotlib/
? Examples gallery:
gallery.html
Contour
Subplots
x = linspace(-3, 3, 200)
y = x
X,Y = meshgrid(x, y)
Z = bivariate_normal(X, Y, sigmaxy=0.5)
contourf(X, Y, Z)
colorbar()
xlabel(¡¯X¡¯)
ylabel(¡¯Y¡¯)
title(r"$\sigma_{XY}$ = 0.5")
n = 128.
x = arange(n)/n
y = sin(0.125*pi*n*x**2)
subplot(221)
plot(x,y,¡¯r¡¯)
xlabel(¡¯x¡¯)
ylabel(r¡¯$sin(0.125n \cdot x?2)$¡¯)
subplot(222)
? Matplotlib colormaps
2013/05/02/matplotlib_colormaps/
................
................
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
- chapter 9 graphics and interaction 9 1 setting up the
- 6 170 tutorial 3 ruby basics mit opencourseware
- matplotlib 2d and 3d plotting in python
- data exploration in python using
- a step by step guide for creating advanced python data
- matplotlib tutorialspoint
- matplotlib quick reference
- basic plotting with python and matplotlib
- introduction to python pandas for data analytics
Related searches
- free excel quick reference sheet
- hospice eligibility quick reference guide
- sba loan quick reference guide
- excel vba quick reference pdf
- excel 2010 quick reference card
- sba quick reference guide 2019
- mla quick reference sheet
- excel 2016 quick reference pdf
- excel quick reference cards 2019
- apa quick reference sheet
- icd 10 quick reference sheets
- icd 10 quick reference list