Matplotlib

matplotlib

matplotlib

matplotlib matplotlib

"Sandro Tosi: Matplotlib for Python Developers, Packt Publishing (2009)"

gnuplot matlab R excel mathematica ...

matplotlib

python

gnuplot

EPS, PDF, PNG, PS, SVG latex

1 import matplotlib.pyplot as plt 2

3 plt.plot([3, 1, 5, 8, 7, 6, 4, 2]) 4 plt.show()

matplotlib

pyplot

"plt.

"

[3, 1, 5, 8, 7, 6, 4, 2]

y

plot

0 0, 1, 2, ..

?

plt plt

x

0, 1, 2, 3, 4, 5, 6, 7

y

x

x

x

1 x=range(10) 2 y= [xt**2 for xt in x] 3 plt.plot(x, y) 4 plt.show()

[xt**2 for xt in x]

x

xt

y

for xt**2

g2

?

1 x=range(10) 2 y=[] 3 for xt in x: 4

y.append(xt**2) 5 plt.plot(x, y) 6 plt.show()

"

range(10) 0 10-1=9 range(x, y, z) x y-1

?

"

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

z

xz

x

range()

numpy

1 import matplotlib.pyplot as plt 2 import numpy as np 3

4 x=np.arange(0.5, 3.0, 0.2) 5 plt.plot(x, [3.0*xt**2--xt**3 for xt in x]) 6 plt.show()

python

range()

arange()

?

plot

show

g4

1 import matplotlib.pyplot as plt 2 import numpy as np 3

4 x=np.arange(0.0, 2.0, 0.1) 5 plt.plot(x, [xt**2 for xt in x]) 6 plt.plot(x, [xt**3 for xt in x]) 7 plt.show()

2

plt.plot(x, [xt**2 for xt in x], x, [xt**3 for xt in x])

plt.plot(x, x**2, x, x**3) arange()

np.arrange

range python

?

numpy

y=ax(x-a)

x

a

0 20

2.5

0 10

0.1

1

plt.grid(True)

True python

plt.axis([xmin, xmax, ymin, ymax])

x

xmin xmax y

plt.axis(ymin= , xmin= )

plt.xlabel("

")

plt.ylabel("

")

xy

plt.title("

")

g5 ymin ymax

plt.plot(x, y, label="

")

x, y

plt.legend()

plt.legend(["

", "

"])

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download