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

Function draw_plot

experiments/human_eval/draw_model_eval_numberline.py:163–208  ·  view source on GitHub ↗
(rows: list[dict[str, object]])

Source from the content-addressed store, hash-verified

161
162
163def draw_plot(rows: list[dict[str, object]]) -> Image.Image:
164 image = Image.new("RGB", (W, H), "white")
165 draw = ImageDraw.Draw(image)
166
167 draw_text_center(draw, (W / 2, 58), "Model Evaluation: Automatic and Human Scores", F_TITLE, COLORS["text"])
168 draw_text_center(
169 draw,
170 (W / 2, 103),
171 "Each row places ModelAutoScore and ModelHumanScore on the same score axis.",
172 F_SUBTITLE,
173 COLORS["muted"],
174 )
175 draw_legend(draw)
176
177 y_axis_top = TOP - 50
178 y_axis_bottom = TOP + (len(rows) - 1) * ROW_H + 54
179 draw_axis(draw, y_axis_top, y_axis_bottom)
180
181 for idx, row in enumerate(rows):
182 y = TOP + idx * ROW_H
183 if idx % 2 == 0:
184 rounded_rect(draw, (70, y - 30, W - 80, y + 31), 10, (249, 251, 253))
185
186 model = str(row["model"])
187 group = str(row["group"])
188 auto = float(row["auto"])
189 human = float(row["human"])
190 xa = x_pos(auto)
191 xh = x_pos(human)
192
193 model_font = F_SMALL_BOLD if len(model) > 31 else F_LABEL
194 draw.text((92, y - 17), model, font=model_font, fill=COLORS["text"])
195 draw_group_chip(draw, 585, y, group)
196
197 draw.line((AXIS_L, y, AXIS_R, y), fill=(234, 238, 243), width=1)
198 draw.line((xa, y + AUTO_Y_OFFSET, xh, y + HUMAN_Y_OFFSET), fill=COLORS["line"], width=4)
199
200 draw.ellipse((xa - 11, y + AUTO_Y_OFFSET - 11, xa + 11, y + AUTO_Y_OFFSET + 11), fill="white", outline=COLORS["auto_dark"], width=4)
201 draw.ellipse((xh - 13, y + HUMAN_Y_OFFSET - 13, xh + 13, y + HUMAN_Y_OFFSET + 13), fill=COLORS["human"], outline=COLORS["human_dark"], width=3)
202
203 draw.text((xa - 33, y - 45), f"{auto:.2f}", font=F_VALUE, fill=COLORS["auto_dark"])
204 draw.text((xh + 18, y - 4), f"{human:.2f}", font=F_VALUE, fill=COLORS["human_dark"])
205
206 note = "Pearson r = 0.9632, Spearman rho = 0.9648 across 14 completed LLM backbones"
207 draw_text_center(draw, (W / 2, H - 72), note, F_SUBTITLE, COLORS["muted"])
208 return image
209
210
211def write_data_snapshot(rows: list[dict[str, object]]) -> None:

Callers 1

mainFunction · 0.70

Calls 6

draw_text_centerFunction · 0.85
draw_axisFunction · 0.85
rounded_rectFunction · 0.85
draw_group_chipFunction · 0.85
draw_legendFunction · 0.70
x_posFunction · 0.70

Tested by

no test coverage detected