Legend
Basic plots
Scales
API
DESIGNED BY NICOLAS P. ROUGIER
1234567 Cheat sheet
Version 3.2
1234567 1234567 002...005 2 0 2 002...005 10 Quick start
API
2.5 2.5 import numpy as np 10010 import matplotlib as mpl 1234567 1234567 import matplotlib.pyplot as plt
X = np.linspace(0, 2*np.pi, 100)
1234567 1234567 Y = np.cos(X)
fig, ax = plt.subplots() ax.plot(X,Y,color='C1')
1234567 1234567 fig.savefig("figure.pdf")
fig.show()
1234567 1234567 Anatomy of a figure
Y axis label
1234567 1234567 4
Major tick
1234567 1234567 Minortick
TEXT 3
Major tick label
1234567 1234567 2 1234567 Y axis label
Anatomy of a figure
Title
Blue signal Red signal
Legend
Grid (linLeinpelot)
(scMatatrekreprslot)
plot([X],Y,[fmt],...)
API
X, Y, fmt, color, marker, linestyle
scatter(X,Y,...)
API
X, Y, [s]izes, [c]olors, markers, cmap
bar[h](x,height,...)
API
x, height, width, bottom, align, color
imshow(Z,[cmap],...)
API
Z, cmap, interpolation, extent, origin
contour[f]([X],[Y],Z,,...) API X, Y, Z, levels, colors, extent, origin
ax.set_[xy]scale(scale,...)
linear
log
-
+ any values 0
+ values > 0
symlog
1 logit
-
+ any values
00
Projections
0
12
1 0 < values < 1
API
subplot(...,projection=p)
p='polar'
p='3d'
p=Orthographic()
API
from cartopy.crs import Cartographic
quiver([X],[Y],U,V,...)
API
X, Y, U, V, C, units, angles
pie(X,[explode],...)
API
Z, explode, labels, colors, radius
text(x,y,text,...)
API
x, y, text, va, ha, size, weight, transform
fill[_between][x]( ... )
API
X, Y1, Y2, color, where
Lines
API
linestyle or ls
"-"
":"
"--"
"-." (0,(0.01,2))
capstyle or dash_capstyle
"butt"
"round"
"projecting"
Markers
API
'.' 'o' 's' 'P' 'X' '*' 'p' 'D' '' '^' 'v' '1' '2' '3' '4' '+' 'x' '|' '_' 4 5 6 7
1
Advanced plots
1234567 Figure
Axes
(linLeinpelot)
Spines
0 0 0.25 0.50 0.75 1 1.25 1.50 1.75 2 2.25 2.50 2.75 3 3.25 3.50 3.75 4
Minor tick label
X axis label
1234567 X axis label
Subplots layout
API
1234567 subplot[s](cols,rows,...) API
fig, axs = plt.subplots(3,3)
123456711111111 G = gridspec(cols,rows,...) API
ax = G[0,:]
1234567 ax.inset_axes(extent)
API
1234567 d=make_axes_locatable(ax) API
ax=d.new_horizontal('10%')
1234567 Getting help 1234567
matplotlib/matplotlib/issues discourse.
000000000.........00112211006285582602570075205050 matplotlib
gitter.im/matplotlib
0505 matplotlib
Matplotlib users mailing list
step(X,Y,[fmt],...) X, Y, fmt, color, marker, where
1234567 boxplot(X,...) X, notch, sym, bootstrap, widths
246
errorbar(X,Y,xerr,yerr,...) X, Y, xerr, yerr, fmt
1234567 hist(X, bins, ...) X, bins, range, density, weights
1234567 violinplot(D,...) D, positions, widths, vert
1234567 barbs([X],[Y], U, V, ...) X, Y, U, V, C, length, pivot, sizes
1234567 eventplot(positions,...) positions, orientation, lineoffsets
1234567 hexbin(X,Y,C,...) X, Y, C, gridsize, bins
1234567 xcorr(X,Y,...) X, Y, normed, detrend
API API API API API API API API API
'$ $''$ $''$ $''$ $''$ $''$ $''$ $''$ $''$ $''$ $''$ $''$ $'
markevery
10
[0, -1]
(25, 5)
[0, 25, -1]
Colors
API
1
0 1
0
C0 b
C1
2g
C2
4
C3
r6
C4 C5 C6 C7 C8 C9 'Cn'
c 8 m 10 y 12 k 14 w 16 'x'
01 01 01 0
DarkRed
0 2 (1,0,0) 0 2 #FF0000 0 2 0.0 0.1 02
Firebrick Crimson IndianRed Salmon
4 6 8 10 12 14 16 (1,0,0,0.75) (1,0,0,0.5) (1,0,0,0.25) 4 6 #FF0000BB 8 10 #FF000088 12 14 #FF000044 16 4 0.2 6 0.3 0.4 80.5 10 0.6 0.7 102.8 01.94 1.016 4 6 8 10 12 14 16
'name' (R,G,B[,A]) '#RRGGBB[AA]' 'x.y'
Colormaps
API
plt.get_cmap(name)
Uniform Sequential Diverging Qualitative Cyclic
viridis magma plasma
Greys YlOrBr Wistia
Spectral coolwarm RdGy
tab10 tab20
twilight
Tick locators
API
from matplotlib import ticker ax.[xy]axis.set_[minor|major]_locator(locator)
ticker.NullLocator()
ticker.MultipleLocator(0.5)
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
ticker.FixedLocator([0, 1, 5])
0
1
5
ticker.LinearLocator(numticks=3)
0.0
2.5
5.0
ticker.IndexLocator(base=0.5, offset=0.25) 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75
ticker.AutoLocator()
0
1
2
3
4
5
ticker.MaxNLocator(n=4)
0.0
1.5
3.0
4.5
ticker.LogLocator(base=10, numticks=15)
103
104
105
106
107
108
109
1010
Tick formatters
API
from matplotlib import ticker ax.[xy]axis.set_[minor|major]_formatter(formatter)
ticker.NullFormatter()
ticker.FixedFormatter(['', '0', '1', ...]) 0 0.25 0.50 1 0.75 0.25 2 0.50 0.75 3 0.25 0.50 0.75 4 0.25 0.50 5
ticker.FuncFormatter(lambda x, pos: "[%.2f]" % x)
[0.00]
[1.00]
[2.00]
[3.00]
[4.00]
[5.00]
ticker.FormatStrFormatter('>%d ................
................
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
- basic plots scales tick locators animation quick start
- matplotlib tutorial
- matplotlib legend multiple columns
- introductory notes matplotlib
- networkx tutorial stanford university
- numpy scipy pandas cheat sheet
- 1 4 matplotlib plotting
- matplotlib a tutorial
- matplotlib tutorial matplotlib plot examples
- cis192 python programming
Related searches
- john legend songland song
- songland john legend pick
- we need love john legend lyrics
- john legend we need love youtube
- songwriter john legend love love
- we need love john legend song
- john legend songland
- john legend song from songland
- matplotlib legend font colors
- legend of the butterfly poem
- ggplot legend title
- add a legend in ggplot