Reja1 Claude Opus 4.7 commited on
Commit
d8460c4
·
1 Parent(s): 67c4322

fix(charts): readable cost axis and label spacing on cost-vs-accuracy

Browse files

Show explicit dollar-formatted ticks instead of a single 10^0 mark,
include each model's cost next to its label, and place labels with
per-model offsets so the upper-right cluster (Gemini 3 Flash, GPT-5.5,
Grok 4.3, Gemini 3.1 Pro) no longer overlaps. Pareto-frontier points
get a darker outline and a soft green fill above the curve.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. scripts/make_neet_2026_charts.py +55 -15
scripts/make_neet_2026_charts.py CHANGED
@@ -12,6 +12,7 @@ from collections import defaultdict
12
  from pathlib import Path
13
 
14
  import matplotlib.pyplot as plt
 
15
  import numpy as np
16
 
17
  # Display label and brand color per OpenRouter model id.
@@ -165,20 +166,28 @@ def chart_main_leaderboard(data: list[dict], out_path: Path):
165
 
166
 
167
  def chart_cost_vs_accuracy(data: list[dict], out_path: Path):
168
- fig, ax = plt.subplots(figsize=(11, 7), dpi=200)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  fig.patch.set_facecolor("white")
170
 
171
- for d in data:
172
- if d["cost"] <= 0:
173
- continue
174
- pct = d["score"] / 720 * 100
175
- ax.scatter(d["cost"], pct, s=320, color=color_for(d["model"]),
176
- edgecolors="white", linewidths=2, zorder=3, alpha=0.95)
177
- ax.annotate(label_for(d["model"]), (d["cost"], pct),
178
- xytext=(d["cost"] * 1.05, pct + 0.6),
179
- fontsize=10.5, fontweight="bold", color="#222")
180
-
181
- pareto_pts = sorted([(d["cost"], d["score"] / 720 * 100) for d in data if d["cost"] > 0])
182
  frontier, best = [], -1
183
  for c, p in pareto_pts:
184
  if p > best:
@@ -186,16 +195,47 @@ def chart_cost_vs_accuracy(data: list[dict], out_path: Path):
186
  best = p
187
  if frontier:
188
  fx, fy = zip(*frontier)
189
- ax.plot(fx, fy, "--", color="#888", linewidth=1.4, alpha=0.5, zorder=1, label="Pareto frontier")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  ax.set_xscale("log")
 
 
 
 
 
 
 
 
 
192
  ax.set_xlabel("Total cost for full exam (USD, log scale)", fontsize=12, fontweight="bold")
193
  ax.set_ylabel("Accuracy (%)", fontsize=12, fontweight="bold")
194
  ax.set_title("NEET 2026 — Cost vs Accuracy (upper-left = best value)",
195
  fontsize=14, pad=14)
196
- pcts = [d["score"] / 720 * 100 for d in data]
197
  ax.set_ylim(min(pcts) - 5, 102)
198
- ax.grid(alpha=0.25, linestyle="-", linewidth=0.5)
199
  ax.set_axisbelow(True)
200
  ax.legend(loc="lower right", frameon=False, fontsize=10)
201
 
 
12
  from pathlib import Path
13
 
14
  import matplotlib.pyplot as plt
15
+ import matplotlib.ticker as mticker
16
  import numpy as np
17
 
18
  # Display label and brand color per OpenRouter model id.
 
166
 
167
 
168
  def chart_cost_vs_accuracy(data: list[dict], out_path: Path):
169
+ # Per-model label offsets (dx_log_factor, dy_pct, ha) to keep labels readable.
170
+ # dx_factor < 1 → label sits LEFT of point; > 1 → RIGHT. ha matches.
171
+ LABEL_OFFSETS = {
172
+ "google/gemini-3-flash-preview": (1.07, +1.30, "left"), # top of cluster, label up-right
173
+ "google/gemini-3.1-pro-preview": (0.93, -0.20, "right"), # rightmost point, label LEFT
174
+ "openai/gpt-5.5": (1.07, +1.30, "left"), # label up-right (clear of Flash)
175
+ "openai/gpt-5.4": (1.07, +1.20, "left"),
176
+ "qwen/qwen3-vl-235b-a22b-thinking": (0.93, +0.10, "right"), # label LEFT (clear of Grok)
177
+ "anthropic/claude-sonnet-4.6": (1.07, -1.30, "left"), # label down-right (clear of Grok)
178
+ "anthropic/claude-haiku-4.5": (1.07, +1.30, "left"),
179
+ "z-ai/glm-4.6v": (1.07, +1.30, "left"),
180
+ "x-ai/grok-4.3": (1.07, -1.40, "left"), # label down-right (clear of Qwen + cluster)
181
+ }
182
+ DEFAULT_OFFSET = (1.07, +0.80, "left")
183
+
184
+ fig, ax = plt.subplots(figsize=(13, 8), dpi=200)
185
  fig.patch.set_facecolor("white")
186
 
187
+ points = [(d, d["score"] / 720 * 100) for d in data if d["cost"] > 0]
188
+
189
+ # Pareto frontier: cheapest cost for each accuracy level (upper envelope).
190
+ pareto_pts = sorted([(d["cost"], pct) for d, pct in points])
 
 
 
 
 
 
 
191
  frontier, best = [], -1
192
  for c, p in pareto_pts:
193
  if p > best:
 
195
  best = p
196
  if frontier:
197
  fx, fy = zip(*frontier)
198
+ ax.plot(fx, fy, "--", color="#888", linewidth=1.5, alpha=0.55, zorder=1,
199
+ label="Pareto frontier")
200
+ ax.fill_between(fx, fy, [102] * len(fx), color="#88CC88", alpha=0.06, zorder=0)
201
+
202
+ on_frontier = set(frontier)
203
+ for d, pct in points:
204
+ is_pareto = (d["cost"], pct) in on_frontier
205
+ ax.scatter(d["cost"], pct, s=360, color=color_for(d["model"]),
206
+ edgecolors="#222" if is_pareto else "white",
207
+ linewidths=2.2 if is_pareto else 2,
208
+ zorder=4, alpha=0.97)
209
+
210
+ dx_factor, dy, ha = LABEL_OFFSETS.get(d["model"], DEFAULT_OFFSET)
211
+ label_x = d["cost"] * dx_factor
212
+ ax.annotate(
213
+ f"{label_for(d['model'])}\n${d['cost']:.2f}",
214
+ (d["cost"], pct),
215
+ xytext=(label_x, pct + dy),
216
+ fontsize=10, fontweight="bold", color="#222", ha=ha,
217
+ bbox=dict(boxstyle="round,pad=0.25", facecolor="white",
218
+ edgecolor="none", alpha=0.85),
219
+ zorder=5,
220
+ )
221
 
222
  ax.set_xscale("log")
223
+ # Explicit log-spaced ticks with $ formatting so the cost axis is readable.
224
+ tick_locs = [0.1, 0.2, 0.3, 0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 5.0]
225
+ ax.xaxis.set_major_locator(mticker.FixedLocator(tick_locs))
226
+ ax.xaxis.set_major_formatter(mticker.FuncFormatter(
227
+ lambda x, _: f"${x:.2f}" if x < 1 else f"${x:.1f}"))
228
+ ax.xaxis.set_minor_locator(mticker.NullLocator())
229
+ costs = [d["cost"] for d, _ in points]
230
+ ax.set_xlim(min(costs) * 0.7, max(costs) * 1.5)
231
+
232
  ax.set_xlabel("Total cost for full exam (USD, log scale)", fontsize=12, fontweight="bold")
233
  ax.set_ylabel("Accuracy (%)", fontsize=12, fontweight="bold")
234
  ax.set_title("NEET 2026 — Cost vs Accuracy (upper-left = best value)",
235
  fontsize=14, pad=14)
236
+ pcts = [pct for _, pct in points]
237
  ax.set_ylim(min(pcts) - 5, 102)
238
+ ax.grid(which="major", axis="both", alpha=0.28, linestyle="-", linewidth=0.6)
239
  ax.set_axisbelow(True)
240
  ax.legend(loc="lower right", frameon=False, fontsize=10)
241