forked from jstac/edtc-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfig4point3.py
More file actions
50 lines (44 loc) · 1.58 KB
/
fig4point3.py
File metadata and controls
50 lines (44 loc) · 1.58 KB
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
import numpy as np
from pyx import *
alpha, s, a = 0.5, 0.25, 7
kstar = ((s*a)**(1/(1 - alpha)))
def h(k):
return s * a * (k**alpha)
def plotcurve(X, Y, canv):
for i in range(len(X)-1):
canv.stroke(path.line(X[i], Y[i], X[i+1], Y[i+1]), [style.linewidth.Thick])
c = canvas.canvas()
upper = 6
# axes
c.stroke(path.line(0, 0, upper, 0), [deco.earrow(size=0.3)])
c.stroke(path.line(0, 0, 0, upper), [deco.earrow(size=0.3)])
# 45 degrees
c.stroke(path.line(0, 0, upper, upper), [style.linestyle.dashed])
# function curve
X = np.linspace(0, upper, 100)
Y = [h(x) for x in X]
plotcurve(X, Y, c)
# arrows
k = 0.5
for i in range(4):
c.stroke(path.line(k, k, k, h(k)),
[deco.earrow(size=0.15), style.linewidth.Thin])
c.stroke(path.line(k, h(k), h(k), h(k)),
[deco.earrow(size=0.15), style.linewidth.Thin])
c.stroke(path.line(k, 0, h(k), 0),
[deco.earrow(size=0.15), style.linewidth.THIN])
k = h(k)
k = 5.8
for i in range(3):
c.stroke(path.line(k, k, k, h(k)),
[deco.earrow(size=0.15), style.linewidth.Thin])
c.stroke(path.line(k, h(k), h(k), h(k)),
[deco.earrow(size=0.15), style.linewidth.Thin])
c.stroke(path.line(k, 0, h(k), 0),
[deco.earrow(size=0.15), style.linewidth.THIN])
k = h(k)
c.stroke(path.line(kstar, 0, kstar, kstar), [style.linestyle.dotted])
c.text(kstar, -0.5, r"k^*", [text.mathmode, text.size.normal])
c.text(upper*1.06, -0.5, r"k_t", [text.mathmode, text.size.normal])
c.text(-0.5, upper*1.06, r"k_{t+1}", [text.mathmode, text.size.normal])
c.writePDFfile("stable45deg")