-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest3.py
More file actions
57 lines (51 loc) · 954 Bytes
/
test3.py
File metadata and controls
57 lines (51 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import math
import pylab # matplotlib
#
# create the x list data
#
# arange() is just like range() but allows float numbers
#
x_list = pylab.arange(0.0, 5.0, 0.01)
#
#
# calculate the y list data
#
y_list = []
#
for x in x_list:
y = math.cos(2*math.pi*x) * math.exp(-x)
y_list.append(y)
#
#
pylab.xlabel("x")
#
pylab.ylabel("cos(2pi * x) * exp(-x)")
#
#
# draw the plot with a blue line 'b' (is default)
#
# using x,y data from the x_list and y_list
#
# (these lists can be brought in from other programs)
#
#
#
# other drawing styles -->
#
# 'r' red line, 'g' green line, 'y' yellow line
#
# 'ro' red dots as markers, 'r.' smaller red dots, 'r+' red pluses
#
# 'r--' red dashed line, 'g^' green triangles, 'bs' blue squares
#
# 'rp' red pentagons, 'r1', 'r2', 'r3', 'r4' well, check out the markers
#
#
#
pylab.plot(x_list, y_list, 'b')
#
#
# save the plot as a PNG image file (optional)
#
pylab.savefig('Fig1.png')