File size: 2,005 Bytes
3676f94 9bc196c 3676f94 9bc196c 3676f94 9bc196c 3676f94 | 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 | """Export the logbook figures as print-resolution PNGs for the poster.
Poster figure slots render at ~756x454 px at 96ppi, and posterly's asset gate
wants >=1.5x that; we export at scale=3 (~2700x1290) to clear it comfortably.
Type size is deliberately NOT touched here. posterly's figure standard (SKILL.md
Step 2 + Gate A) sets legibility with two levers -- autocrop the whitespace so the
plot fills its box, then size the figure at 70-100% of card width for AR>1.3 --
not by inflating fonts. Scaling the type up here previously overran the 900px
canvas and clipped the titles into the y-axis labels.
"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import importlib.util
# kaleido otherwise picks up snap chromium, which cannot run headless here;
# reuse the Playwright chromium we already installed for the poster gates.
_PW = os.path.expanduser("~/.cache/ms-playwright/chromium-1228/chrome-linux64/chrome")
if os.path.exists(_PW):
os.environ["BROWSER_PATH"] = _PW
os.environ["CHROME_PATH"] = _PW
spec = importlib.util.spec_from_file_location("mf", os.path.join(
os.path.dirname(os.path.abspath(__file__)), "make_figures.py"))
mf = importlib.util.module_from_spec(spec)
mf.__name__ = "mf" # keep its __main__ block from firing
spec.loader.exec_module(mf)
OUTDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "poster", "images")
os.makedirs(OUTDIR, exist_ok=True)
# monkeypatch save() to also emit a PNG
orig_save = mf.save
def save_png(fig, name, rows, header):
p, c = orig_save(fig, name, rows, header)
png = os.path.join(OUTDIR, name + ".png")
fig.update_layout(width=900, height=430)
fig.write_image(png, scale=3)
print(" png:", png)
return p, c
mf.save = save_png
for fn in (mf.fig_speedup, mf.fig_k_law, mf.fig_ic_hist, mf.fig_scores,
mf.fig_ablation_score, mf.fig_temperature):
try:
fn()
except Exception as e:
print("skip", fn.__name__, e)
print("done")
|