-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_nested_arrow.py
More file actions
55 lines (43 loc) · 1.5 KB
/
plot_nested_arrow.py
File metadata and controls
55 lines (43 loc) · 1.5 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
51
52
53
54
55
"""
Figure 1 from the thesis:
Schematic nested simulation diagram with arrows showing outer and inner scenarios.
"""
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
fig, ax = plt.subplots(figsize=(8, 5))
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.axis('off')
# Time labels
ax.text(0.1, 0.02, 't=0', ha='center', fontsize=11, fontweight='bold')
ax.text(0.4, 0.02, r'$T_0$', ha='center', fontsize=11, fontweight='bold')
ax.text(0.8, 0.02, r'$T_1$', ha='center', fontsize=11, fontweight='bold')
# Labels
ax.text(0.15, 0.95, 'outer scenarios', ha='center', fontsize=10)
ax.text(0.55, 0.95, 'inner scenarios', ha='center', fontsize=10)
# Outer scenarios: from (0.1, 0.5) to 3 endpoints at T0
x_start = 0.1
x_mid = 0.4
x_end = 0.8
y_center = 0.5
outer_y = [0.8, 0.5, 0.2]
arrow_props = dict(arrowstyle='->', lw=1.5, color='black')
for y in outer_y:
ax.annotate('', xy=(x_mid, y), xytext=(x_start, y_center),
arrowprops=arrow_props)
# Inner scenarios: from each T0 endpoint to 3 endpoints at T1
inner_offsets = [0.1, 0.0, -0.1]
for y_mid in outer_y:
for dy in inner_offsets:
y_end = y_mid + dy
y_end = max(0.05, min(0.95, y_end))
ax.annotate('', xy=(x_end, y_end), xytext=(x_mid, y_mid),
arrowprops=arrow_props)
# Dots at nodes
ax.plot(x_start, y_center, 'ko', markersize=5)
for y in outer_y:
ax.plot(x_mid, y, 'ko', markersize=5)
fig.tight_layout()
fig.savefig('plot_nested_arrow.png', dpi=150)
print("Saved: plot_nested_arrow.png")
plt.show()