我制作了一个带有三个变量S,T,L的循环的函数。这些变量中的每一个都有一个小值,中值和大值(例如Ss,Sm,Sb)。然后,通过使用函数(公式),我计算了27个(每个值彼此相关)取决于距离的函数。该图看起来不错,但是,我无法绘制带有标签的图例。我想为每个功能添加图例“ Sm,Tm,Bm”或“ Sm,Tb,Bm”。
#variables
S = namedtuple('S', ['b', 'm', 's'])
T = namedtuple('T', ['b', 'm', 's'])
L = namedtuple('L', ['b', 'm', 's'])
s = S(b=0.00168, m=0.00112, s=0.000560)
t = T(b=750.0, m=645.0, s=550.0)
l = L(b=0.07, m=0.05, s=0.02)
distance = np.zeros((100))
result = np.zeros((3, 3, 3, 100))
def jimmy_jao_formula(m: int, sx: float, tx: float, lx: float):
Ho = 2
w = 0.26
p = (1.0/math.sqrt(2)) * (((lx/tx)**2.0 + (w*sx/tx)**2)**(1/2) + (lx/tx))**(1/2)
Hx = Ho * math.exp(-p*m)
return Hx
for mi, m in enumerate(range(0, 3000, 30)):
print(f'Working on distance {m} - step {mi}')
for si, sx in enumerate(s):
for ti, tx in enumerate(t):
for li, lx in enumerate(l):
hx = jimmy_jao_formula(m, sx, tx, lx)
#formula Jimmy Jao
result[si, ti, li, mi] = hx
distance[mi] = m
# plot the result.
plt.figure(figsize=(20,10))
for a in range(3):
for b in range(3):
for c in range(3):
plt.plot(distance, result[a, b, c, :])