File size: 4,275 Bytes
a071401 | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | # =========================================================
# Academic-style Ablation Figure
# =========================================================
import matplotlib.pyplot as plt
import numpy as np
configs = [
"Biomni\n(Baseline)",
"+MCP\nInfra.",
"+MCP Infra.\n +Graph-Sca\n Planning",
]
# 仅更新此处的数字,完全对齐表格中的最新数据
metrics = {
"BioAgentBench": [39.67, 42.68, 46.84],
"LAB-Bench DbQA": [57.46, 66.35, 67.29],
"LAB-Bench SeqQA": [84.76, 89.84, 90.48],
}
# =========================================================
# Muted academic palette
# =========================================================
fill_colors = [
"#E5E7EB", # soft gray
"#D6E4F0", # muted blue
"#E8D6DC", # muted wine
]
edge_colors = [
"#6B7280",
"#4B6A88",
"#8A3D5D",
]
# =========================================================
# Style
# =========================================================
plt.rcParams.update(
{
"font.family": "DejaVu Sans",
"font.size": 10,
"axes.titlesize": 12,
"xtick.labelsize": 9,
"ytick.labelsize": 9.5,
"pdf.fonttype": 42,
"ps.fonttype": 42,
}
)
fig, axes = plt.subplots(
1,
3,
figsize=(8.4, 2.85),
sharey=True,
)
y = np.arange(len(configs))
for idx, (ax, (title, values)) in enumerate(zip(axes, metrics.items())):
values = np.array(values)
baseline = values[0]
span = values.max() - values.min()
x_min = values.min() - span * 0.28 - 0.6
x_max = values.max() + span * 0.52 + 1.2
ax.set_xlim(x_min, x_max)
# subtle baseline reference
ax.axvline(
baseline,
color="#C7CCD4",
linestyle="--",
linewidth=0.9,
zorder=1,
)
for i, val in enumerate(values):
# main bar
ax.barh(
y[i],
val - x_min,
left=x_min,
height=0.42,
color=fill_colors[i],
edgecolor=edge_colors[i],
linewidth=1.15,
zorder=3,
)
# subtle inner highlight
ax.barh(
y[i],
(val - x_min) * 0.52,
left=x_min,
height=0.42,
color="white",
alpha=0.12,
linewidth=0,
zorder=4,
)
# value inside bar
ax.text(
val - span * 0.06,
y[i],
f"{val:.1f}",
ha="right",
va="center",
fontsize=10,
color=edge_colors[i],
fontweight="bold" if i == 2 else "normal",
)
# gain
if i > 0:
gain = val - baseline
ax.text(
val + span * 0.14 + 0.2,
y[i],
f"+{gain:.1f}",
ha="left",
va="center",
fontsize=8.8,
color="#16924A",
)
# panel title
ax.set_title(title, pad=7, fontweight="bold")
ax.set_xticks([])
# minimal style
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["bottom"].set_visible(False)
ax.spines["left"].set_color("#D1D5DB")
ax.spines["left"].set_linewidth(0.8)
if idx == 0:
ax.set_yticks(y)
ax.set_yticklabels(configs)
else:
ax.tick_params(axis="y", left=False, labelleft=False)
# top-to-bottom
axes[0].invert_yaxis()
# =========================================================
# Figure title
# =========================================================
fig.suptitle(
"Ablation of MCP Infrastructure and Graph Planning",
fontsize=13.5,
fontweight="bold",
y=1.02,
)
# =========================================================
# Layout
# =========================================================
fig.subplots_adjust(
left=0.16,
right=0.985,
top=0.72,
bottom=0.15,
wspace=0.08,
)
# =========================================================
# Save
# =========================================================
fig.savefig("ablation_academic.pdf", bbox_inches="tight")
fig.savefig("ablation_academic.png", dpi=500, bbox_inches="tight")
fig.savefig("ablation_academic.svg", bbox_inches="tight") |