1 import numpy as np, matplotlib.pyplot as plt
   2 from _utils.plot_utils import setup_style, save_fig, PALETTE, COLORS, _lighten
   3 setup_style()
   4 np.random.seed(42)
   5 
   6 # Pareto 前沿数据
   7 t = np.linspace(0, 1, 80)
   8 pareto_f1 = 0.8 + 4.8 * t          # 目标1:农业产量(标准化)
   9 pareto_f2 = 4.5 - 4.0 * t**0.7     # 目标2:缺水缺口
  10 
  11 fig, ax = plt.subplots(figsize=(7, 6))
  12 
  13 # 可行域填充(Pareto 前沿上方)
  14 ax.fill_between(pareto_f1, pareto_f2, 5.5, alpha=0.12, color=PALETTE[0], zorder=0)
  15 ax.text(3.2, 3.5, '可行域', fontsize=13, color=PALETTE[0], fontweight='bold', alpha=0.5)
  16 ax.text(1.5, 1.2, '非可行域', fontsize=11, color=COLORS['ref_line'], alpha=0.5)
  17 
  18 # Pareto 前沿线(粗实线)
  19 ax.plot(pareto_f1, pareto_f2, '-', color=COLORS['text'], linewidth=3, zorder=5, label='Pareto 最优前沿')
  20 
  21 # 极端解标注 — 不同 marker + 颜色标注框
  22 # 缺水最小极端解(左上)
  23 ax.scatter(pareto_f1[0], pareto_f2[0], marker='s', s=150, color=COLORS['up'],
  24            edgecolor='white', linewidth=1.5, zorder=6)
  25 ax.annotate('缺水最小极端解\n(min$G_t$,$Z_1$ 最小)',
  26             xy=(pareto_f1[0], pareto_f2[0]),
  27             xytext=(pareto_f1[0] + 0.3, pareto_f2[0] + 0.3),
  28             fontsize=8.5, color=COLORS['up'], fontweight='bold',
  29             arrowprops=dict(arrowstyle='->', color=COLORS['up'], lw=1.2),
  30             bbox=dict(boxstyle='round,pad=0.4', facecolor='white',
  31                       edgecolor=COLORS['up'], alpha=0.9))
  32 
  33 # 均衡折中解(中间,五角星)
  34 knee_idx = len(t) // 2 + 5
  35 ax.scatter(pareto_f1[knee_idx], pareto_f2[knee_idx], marker='*', s=300,
  36            color=COLORS['highlight'], edgecolor='white', linewidth=1.5, zorder=6)
  37 ax.annotate('均衡折中解(膝点)\n$\\omega_1 Z_1 + \\omega_2 G_t$ 最优',
  38             xy=(pareto_f1[knee_idx], pareto_f2[knee_idx]),
  39             xytext=(pareto_f1[knee_idx] + 0.5, pareto_f2[knee_idx] + 0.6),
  40             fontsize=8.5, color=COLORS['highlight'], fontweight='bold',
  41             arrowprops=dict(arrowstyle='->', color=COLORS['highlight'], lw=1.2),
  42             bbox=dict(boxstyle='round,pad=0.4', facecolor='white',
  43                       edgecolor=COLORS['highlight'], alpha=0.9))
  44 
  45 # 产量最大化极端解(右下,菱形)
  46 ax.scatter(pareto_f1[-1], pareto_f2[-1], marker='D', s=120, color=COLORS['down'],
  47            edgecolor='white', linewidth=1.5, zorder=6)
  48 ax.annotate('产量最大化极端解\n(max$Z_1$,$G_t$ 较大)',
  49             xy=(pareto_f1[-1], pareto_f2[-1]),
  50             xytext=(pareto_f1[-1] - 1.5, pareto_f2[-1] - 0.5),
  51             fontsize=8.5, color=COLORS['down'], fontweight='bold',
  52             arrowprops=dict(arrowstyle='->', color=COLORS['down'], lw=1.2),
  53             bbox=dict(boxstyle='round,pad=0.4', facecolor='white',
  54                       edgecolor=COLORS['down'], alpha=0.9))
  55 
  56 # 方向箭头
  57 ax.annotate('', xy=(2.0, 0.15), xytext=(0.5, 0.15),
  58             arrowprops=dict(arrowstyle='->', color=COLORS['ref_line'], lw=1.2, linestyle='--'))
  59 ax.text(1.25, 0.0, '$Z_1$ 增大方向', fontsize=8, color=COLORS['ref_line'], ha='center')
  60 ax.annotate('', xy=(0.3, 1.8), xytext=(0.3, 0.5),
  61             arrowprops=dict(arrowstyle='->', color=COLORS['ref_line'], lw=1.2, linestyle='--'))
  62 ax.text(0.15, 1.15, '$G_t$ 减小方向', fontsize=8, color=COLORS['ref_line'],
  63         ha='center', rotation=90)
  64 
  65 ax.set_xlabel('农业产量 $Z_1$(标准化值)', fontsize=11)
  66 ax.set_ylabel('缺水缺口 $G_t$(标准化值)', fontsize=11)
  67 ax.legend(frameon=False, labelspacing=0.35, handlelength=1.6, fontsize=9, loc='best')
  68 ax.set_xlim(0, 6.2)
  69 ax.set_ylim(0, 5.5)
  70 ax.spines['top'].set_visible(False)
  71 ax.spines['right'].set_visible(False)
  72 fig.tight_layout()
  73 save_fig(fig, 'figures/fig_pareto.pdf')