6
6
"""
7
7
8
8
import pylab as plt
9
+ plt .interactive (False )
10
+
9
11
10
12
def retire (monthly , rate , terms ):
11
13
savings = [0 ]
12
14
base = [0 ]
13
- monthlyRate = rate / 12
15
+ monthlyRate = rate / 12
14
16
for i in range (terms ):
15
17
base += [i ]
16
- savings += [savings [- 1 ]* (1 + monthlyRate ) + monthly ]
18
+ savings += [savings [- 1 ] * (1 + monthlyRate ) + monthly ]
17
19
return base , savings
18
-
20
+
21
+
19
22
def displayRetirementWithMonthlies (monthlies , rate , terms ):
20
23
plt .figure ('retireMonth' )
21
24
plt .clf ()
22
25
for monthly in monthlies :
23
26
xvals , yvals = retire (monthly , rate , terms )
24
- plt .plot (xvals , yvals , label = 'retire:' + str (monthly ))
25
- plt .legend (loc = 'upper left' )
27
+ plt .plot (xvals , yvals , label = 'retire:' + str (monthly ))
28
+ plt .legend (loc = 'upper left' )
29
+
30
+ displayRetirementWithMonthlies ([500 , 600 , 700 , 800 , 900 , 1000 , 1100 ], .05 , 40 * 12 )
31
+
26
32
27
- displayRetirementWithMonthlies ([500 , 600 , 700 , 800 , 900 , 1000 , 1100 ], .05 , 40 * 12 )
28
-
29
33
def displayRetirementWithRates (monthly , rates , terms ):
30
34
plt .figure ('retireRate' )
31
35
plt .clf ()
32
36
for rate in rates :
33
37
xvals , yvals = retire (monthly , rate , terms )
34
- plt .plot (xvals , yvals ,
35
- label = 'retire:' + str (monthly )+ ':' + str (int (rate * 100 )))
36
- plt .legend (loc = 'upper left' )
38
+ plt .plot (xvals , yvals ,
39
+ label = 'retire:' + str (monthly ) + ':' + str (int (rate * 100 )))
40
+ plt .legend (loc = 'upper left' )
41
+
42
+
43
+ displayRetirementWithRates (800 , [.03 , .05 , .07 ], 40 * 12 )
37
44
38
- displayRetirementWithRates (800 ,[.03 , .05 , .07 ], 40 * 12 )
39
45
40
-
41
46
def displayRetirementWithMonthsAndRates (monthlies , rates , terms ):
42
47
plt .figure ('retireBoth' )
43
48
plt .clf ()
44
- plt .xlim (30 * 12 , 40 * 12 )
49
+ plt .xlim (30 * 12 , 40 * 12 )
45
50
for monthly in monthlies :
46
51
for rate in rates :
47
52
xvals , yvals = retire (monthly , rate , terms )
48
53
plt .plot (xvals , yvals ,
49
- label = 'retire:' + str (monthly )+ ':' + str (int (rate * 100 )))
50
- plt .legend (loc = 'upper left' )
51
-
52
- displayRetirementWithMonthsAndRates ([500 , 700 , 900 , 1100 ],
53
- [.03 , .05 , .07 ], 40 * 12 )
54
-
55
- #def displayRetirementWithMonthsAndRates(monthlies, rates, terms):
54
+ label = 'retire:' + str (monthly ) + ':' + str (int (rate * 100 )))
55
+ plt .legend (loc = 'upper left' )
56
+
57
+
58
+ displayRetirementWithMonthsAndRates ([500 , 700 , 900 , 1100 ],
59
+ [.03 , .05 , .07 ], 40 * 12 )
60
+ plt .show ()
61
+
62
+ # def displayRetirementWithMonthsAndRates(monthlies, rates, terms):
56
63
# plt.figure('retireBoth')
57
64
# plt.clf()
58
65
# plt.xlim(30*12, 40*12)
@@ -69,9 +76,6 @@ def displayRetirementWithMonthsAndRates(monthlies, rates, terms):
69
76
# label = 'retire:'+str(monthly)+ ':' + str(int(rate*100)))
70
77
# plt.legend(loc = 'upper left')
71
78
#
72
- #displayRetirementWithMonthsAndRates([500, 700, 900, 1100],
79
+ # displayRetirementWithMonthsAndRates([500, 700, 900, 1100],
73
80
# [.03, .05, .07], 40*12)
74
- #
75
-
76
-
77
-
81
+ #
0 commit comments