MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / draw_plot

Function draw_plot

experiments/human_eval/draw_model_eval_ggbench_style.py:169–220  ·  view source on GitHub ↗
(rows: list[dict[str, object]])

Source from the content-addressed store, hash-verified

167
168
169def draw_plot(rows: list[dict[str, object]]) -> Image.Image:
170 image = Image.new("RGB", (W, H), "white")
171 draw = ImageDraw.Draw(image)
172
173 draw.text((PLOT_L, 58), "Automatic--Human Alignment in Model Comparison", font=F_TITLE, fill=COLORS["text"])
174 draw.text((PLOT_L, 112), "Each point is one completed LLM backbone.", font=F_NOTE, fill=COLORS["muted"])
175 draw_legend(draw)
176
177 draw.rectangle((PLOT_L, PLOT_T, PLOT_R, PLOT_B), outline=COLORS["axis"], width=3)
178 for tick in [63.5, 64.0, 64.5, 65.0]:
179 x = x_pos(tick)
180 draw.line((x, PLOT_T, x, PLOT_B), fill=COLORS["grid"], width=2)
181 centered_text(draw, x, PLOT_B + 36, f"{tick:.1f}", F_TICK, COLORS["muted"])
182 for tick in [65, 70, 75, 80, 85, 90, 95]:
183 y = y_pos(tick)
184 draw.line((PLOT_L, y, PLOT_R, y), fill=COLORS["grid"], width=2)
185 centered_text(draw, PLOT_L - 48, y, str(tick), F_TICK, COLORS["muted"])
186
187 centered_text(draw, (PLOT_L + PLOT_R) / 2, PLOT_B + 92, "ModelAutoScore", F_AXIS, COLORS["text"])
188 draw_rotated_axis_label(image, "ModelHumanScore")
189
190 xs = [float(row["auto"]) for row in rows]
191 ys = [float(row["human"]) for row in rows]
192 slope, intercept = regression(xs, ys)
193 x1, x2 = min(xs), max(xs)
194 y1, y2 = slope * x1 + intercept, slope * x2 + intercept
195 draw.line((x_pos(x1), y_pos(y1), x_pos(x2), y_pos(y2)), fill=COLORS["line"], width=8)
196
197 for row in sorted(rows, key=lambda r: float(r["human"])):
198 key = str(row["model_key"])
199 x = x_pos(float(row["auto"]))
200 y = y_pos(float(row["human"]))
201 fill = COLORS["closed"] if row["group"] == "Closed" else COLORS["open"]
202 edge = COLORS["closed_edge"] if row["group"] == "Closed" else COLORS["open_edge"]
203 draw.ellipse((x - 15, y - 15, x + 15, y + 15), fill=fill, outline=edge, width=4)
204 ox, oy = LABEL_OFFSETS.get(key, (16, -16))
205 label = str(row["model"])
206 lx, ly = x + ox, y + oy
207 width, height = text_size(draw, label, F_LABEL)
208 draw.line((x, y, lx, ly + height / 2), fill=(204, 211, 221), width=2)
209 draw.rounded_rectangle((lx - 6, ly - 4, lx + width + 6, ly + height + 4), radius=7, fill=(255, 255, 255))
210 draw.text((lx, ly), label, font=F_LABEL, fill=COLORS["text"])
211
212 r = pearson(xs, ys)
213 box = (1585, 925, 2040, 1095)
214 draw.rounded_rectangle(box, radius=18, fill=(248, 250, 252), outline=(224, 230, 236), width=2)
215 draw.text((1142, 1068), "Correlation", font=F_NOTE_BOLD, fill=COLORS["text"])
216 draw.text((1142, 1110), f"Pearson's r = {r:.4f}", font=F_NOTE_BOLD, fill=COLORS["line"])
217 draw.text((1142, 1150), "n = 14 completed LLM backbones", font=F_NOTE, fill=COLORS["muted"])
218
219 draw.text((PLOT_L, 1355), "Source: model-comparison human evaluation summary.", font=F_NOTE, fill=COLORS["muted"])
220 return image
221
222
223def write_data(rows: list[dict[str, object]]) -> None:

Callers 1

mainFunction · 0.70

Calls 9

draw_rotated_axis_labelFunction · 0.85
getMethod · 0.80
draw_legendFunction · 0.70
x_posFunction · 0.70
centered_textFunction · 0.70
y_posFunction · 0.70
regressionFunction · 0.70
text_sizeFunction · 0.70
pearsonFunction · 0.70

Tested by

no test coverage detected