1 import numpy as np, matplotlib.pyplot as plt 2 from _utils.plot_utils import setup_style, save_fig, PALETTE, COLORS 3 setup_style() 4 np.random.seed(42) 5 6 steps = np.arange(1, 13) 7 models = { 8 '本文模型': 0.95 * np.exp(-0.08 * steps) + 0.02 * np.random.randn(len(steps)), 9 'LSTM': 0.90 * np.exp(-0.10 * steps) + 0.03 * np.random.randn(len(steps)), 10 'ARIMA': 0.85 * np.exp(-0.15 * steps) + 0.04 * np.random.randn(len(steps)), 11 } 12 13 fig, ax = plt.subplots(figsize=(7, 4.5)) 14 highlight_index = 0 # 重点系列的位置,与显示名称无关 15 ax.grid(True, linestyle='--', alpha=0.15); ax.set_axisbelow(True) 16 17 for i, (name, vals) in enumerate(models.items()): 18 is_ours = i == highlight_index 19 lw = 2.5 if is_ours else 1.5 20 alpha = 1.0 if is_ours else 0.6 21 ax.plot(steps, vals, color=PALETTE[i], linewidth=lw, marker='o', markersize=5, 22 markeredgecolor='white', markeredgewidth=1, label=name, alpha=alpha, zorder=3) 23 if is_ours: 24 std = 0.03 * np.sqrt(steps) 25 ax.fill_between(steps, vals-std, vals+std, alpha=0.12, color=PALETTE[i]) 26 27 # 阈值线 28 ax.axhline(0.5, color=COLORS['ref_line'], linewidth=0.8, linestyle='--', alpha=0.5) 29 ax.text(steps[-1]+0.3, 0.5, '可用阈值', fontsize=8, color=COLORS['ref_line'], va='center') 30 31 ax.set_xlabel('预测步长', fontsize=11); ax.set_ylabel('R² 分数', fontsize=11) 32 ax.set_xticks(steps) 33 ax.legend(frameon=False, labelspacing=0.35, handlelength=1.6, fontsize=9, loc='best') 34 ax.spines['top'].set_visible(False); ax.spines['right'].set_visible(False) 35 fig.tight_layout() 36 save_fig(fig, 'figures/fig_multistep_decay.pdf')