code: def draw_anytime_result_with_p1(
      result_dir,
      y_acc_list_arr,
      x_T_list,
      y_acc_list_arr_p1,
      x_T_list_p1,
      x_acc_train,
      y_acc_train_l,
      y_acc_train_m,
      y_acc_train_h,
      annotations,
      lv,
      name_img,
      dataset,
      max_value,
      x1_lim=[],
      x2_lim=[],
  ):
      fig, (ax1, ax2) = plt.subplots(
          2,
          1,
          sharex=True,
          dpi=100,
          gridspec_kw={"height_ratios": [6, 1]},
      )
  
      shade_degree = 0.2
  
      # plot simulate result of train-based line
      ax1.plot(
          x_acc_train,
          y_acc_train_m,
          mark_list[-3] + line_shape_list[0],
          label="Training-Based MS",
          markersize=mark_size_list[-3],
      )
      ax1.fill_between(
          x_acc_train, y_acc_train_l, y_acc_train_h, alpha=shade_degree
      )
      ax2.fill_between(
          x_acc_train, y_acc_train_l, y_acc_train_h, alpha=shade_degree
      )
  
      # plot simulate result of system
      exp = np.array(y_acc_list_arr_p1)
      sys_acc_p1_h = np.quantile(exp, 0.75, axis=0)
      sys_acc_p1_m = np.quantile(exp, 0.5, axis=0)
      sys_acc_p1_l = np.quantile(exp, 0.25, axis=0)
      ax1.plot(
          x_T_list_p1,
          sys_acc_p1_m,
          mark_list[-2] + line_shape_list[1],
          label="Training-Free MS",
          markersize=mark_size_list[-2],
      )
      ax1.fill_between(
          x_T_list_p1, sys_acc_p1_l, sys_acc_p1_h, alpha=shade_degree
      )
      ax2.fill_between(
          x_T_list_p1, sys_acc_p1_l, sys_acc_p1_h, alpha=shade_degree
      )
  
      # plot simulate result of system
      exp = np.array(y_acc_list_arr)
      sys_acc_h = np.quantile(exp, 0.75, axis=0)
      sys_acc_m = np.quantile(exp, 0.5, axis=0)
      sys_acc_l = np.quantile(exp, 0.25, axis=0)
      ax1.plot(
          x_T_list,
          sys_acc_m,
          mark_list[-1] + line_shape_list[2],
          label="2Phase-MS",
          markersize=mark_size_list[-1],
      )
      ax1.fill_between(
          x_T_list, sys_acc_l, sys_acc_h, alpha=shade_degree
      )
      ax2.fill_between(
          x_T_list, sys_acc_l, sys_acc_h, alpha=shade_degree
      )
  
      print(
          f"speed-up on {dataset} = {x_acc_train[-1] / x_T_list[-2]}, "
          f"t_train = {x_acc_train[-1]}, t_f = {x_T_list[-2]}"
      )
  
      for i in range(len(annotations)):
          ele = annotations[i]
          if ele[1] < lv:
              # convert to mins
              ax2.plot(
                  ele[2] / 60,
                  ele[1],
                  mark_list[i],
                  label=ele[0],
                  markersize=set_marker_point,
              )
          else:
              ax1.plot(
                  ele[2] / 60,
                  ele[1],
                  mark_list[i],
                  label=ele[0],
                  markersize=set_marker_point,
              )
          # ax2.scatter(ele[2]/60, ele[1]* 0.01, s=100, color="red")
          # ax2.annotate(ele[0], (ele[2]/60, ele[1] * 0.01))
  
      if len(x1_lim) > 0 and len(x2_lim) > 0:
          ax1.set_ylim(x1_lim[0], x1_lim[1])  # 子图1设置y轴范围，只显示部分图
          ax2.set_ylim(x2_lim[0], x2_lim[1])  # 子图2设置y轴范围，只显示部分图
  
      ax1.spines["bottom"].set_visible(False)  # 关闭子图1中底部脊
      ax2.spines["top"].set_visible(False)  ##关闭子图2中顶部脊
      ax2.set_xticks(range(0, 31, 1))
  
      d = 0.85  # 设置倾斜度
      # 绘制断裂处的标记
      kwargs = dict(
          marker=[(-1, -d), (1, d)],
          markersize=set_marker_size,
          linestyle="none",
          color="r",
          mec="r",
          mew=1,
          clip_on=False,
      )
      ax1.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
      ax2.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)
  
      plt.xscale("log")
      ax1.grid()
      ax2.grid()
      plt.xlabel(
          r"Response Time Threshold $T_{max}$ (min)",
          fontsize=set_font_size,
      )
      ax1.set_ylabel(f"Test Acc on {'In-16'}", fontsize=set_font_size)
      # ax1.legend(ncol=1, fontsize=set_lgend_size)
      # ax2.legend(fontsize=set_lgend_size)
  
      ax1.xaxis.label.set_size(set_tick_size)
      ax1.yaxis.label.set_size(set_tick_size)
      # ax1.set_xticks([])
  
      ax2.xaxis.label.set_size(set_tick_size)
      ax2.yaxis.label.set_size(set_tick_size)
  
      ax1.yaxis.set_major_locator(MaxNLocator(nbins=4, integer=True))
  
      ax1.axhline(
          max_value,
          color="r",
          linestyle="-",
          label="Global Best Accuracy",
      )
  
      tick_values = [0.01, 0.1, 1, 10, 100, 1000]
      ax2.set_xticks(tick_values)
      ax2.set_xticklabels(
          [f"$10^{{{int(np.log10(val))}}}$" for val in tick_values]
      )
  
      # this is for unique hash
      export_legend(
          fig,
          colnum=3,
          unique_labels=[
              "TE-NAS (Training-Free)",
              "ENAS (Weight sharing)",
              "KNAS (Training-Free)",
              "DARTS-V1 (Weight sharing)",
              "DARTS-V2 (Weight sharing)",
              "Training-Based MS",
              "Training-Free MS",
              "2Phase-MS",
              "Global Best Accuracy",
          ],
      )
      plt.tight_layout()
      fig.savefig(
          f"{result_dir}/any_time_{name_img}_p1_from_0.1_sec.pdf",
          bbox_inches="tight",
      )
  
file_path: singa/examples/model_selection/TRAILS-Database-Native-Model-Selection/internal/ml/model_selection/exps/draw_img_lib.py
imports: import os
  from matplotlib import pyplot
  import seaborn
  import numpy
  import palettable
  from matplotlib.ticker import MaxNLocator
  import numpy
  from src.common.constant import Config
  import matplotlib
label_desc: Use image node_id 4 for calling a global function with example usage: draw_anytime_result_with_p1(result_dir, y_acc_list_arr, x_T_list, y_acc_list_arr_p1, x_T_list_p1, x_acc_train, y_acc_train_l, y_acc_train_m, y_acc_train_h, annotations, lv, name_img, dataset, max_value, x1_lim, x2_lim) without return types