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

2

3

4

import

?matplotlib.pyplot

?as

?plt

?

plt.plot([3,

?1,

?5,

?8,

?7,

?6,

?4,

?2])

plt.show()

matplotlib

pyplot

¡±plt.

?

¡±

plt

plt

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

y

x

plot

0

y

x

y

x=range(10)

y=

?[xt**2

?for

?xt

?in

?x]

plt.plot(x,

?y)

plt.show()

for

xt

g2

?

[xt**2 for xt in x]

x

x

0, 1, 2, ..

x

1

2

3

4

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

xt**2

1

2

3

4

5

6

x=range(10)

y=[]

for

?xt

?in

?x:

?

?

?

?y.append(xt**2)

plt.plot(x,

?y)

plt.show()

?

¡±

¡±

range(10) 0

10-1=9

range(x, y, z) x

y-1

z

x

range()

numpy

1

2

3

4

5

6

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

x z

python

arange()

import

?matplotlib.pyplot

?as

?plt

import

?numpy

?as

?np

?

x=np.arange(0.5,

?3.0,

?0.2)

plt.plot(x,

?[3.0*xt**2-?©\xt**3

?for

?xt

?in

?x])

plt.show()

range()

?

plot

show

1

2

3

4

5

6

7

g4

import

?matplotlib.pyplot

?as

?plt

import

?numpy

?as

?np

?

x=np.arange(0.0,

?2.0,

?0.1)

plt.plot(x,

?[xt**2

?for

?xt

?in

?x])

plt.plot(x,

?[xt**3

?for

?xt

?in

?x])

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()

range

np.arrange

numpy

python

y=ax(x-a)

a

0

x

20

0

2.5

plt.grid(True)

plt.axis(ymin= , xmin= )

plt.xlabel("

")

plt.ylabel("

x y

plt.title("

")

")

plt.plot(x, y, label="

")

x, y

plt.legend()

plt.legend(["

", "

"])

ymin

0.1

1

g5

True python

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

x

xmin

xmax y

10

ymax

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

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

Google Online Preview   Download