"""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")