A general tutorial here (pdf, html). 中文版

Note: if you are not using ipython, you need to include

from pylab import *

at the beginning of your code.

Screenshots (Page 181): you can look up functions for certain kinds of plots.

Plots/Scatter plots

Simple scatter plots

import matplotlib.pyplot as plt

fig = plt.figure(figsize = (4,5), dpi = 80)      # create a 4*5 inches plot

plt.plot([1,2,3,4], [1,4,9,16], ‘ro’)     # the optional third argument is similar to matlab (default = ‘b-‘). colors = ‘b’,’g’,’r’,’c’,’m’,’y’,’k’,’w’; shape = ‘-‘,’–‘,’s’,’^’,…,(more)

plt.axis([0, 6, 0, 20])

plt.title(‘This is a title’)

plt.xlabel(‘X axis’)

plt.ylabel(‘Y axis’)




Page 13, Page 101


Page 117

Adjust subplots/text

plt.tight_layout()      # (Reference)

Mathematical Expressions

plt.title(r’$\alpha > \beta$’)    # similar to LaTex

r’$\sum_{i=0}^\infty x_i$’

r’$s(t) = \mathcal{A}\mathrm{sin}(2 \omega t)$’

remove points boundary

edgecolors = ‘none’

to be continued…