LayMesh#
Gradient comparison gallery: 30 original recipes, actual exports and explained reference differences.
Create scientific figures and precise physical layouts from readable code. Combine native plots, images, vector shapes, text and formulas in an editable project, then export static figures or multipage presentations.
Documentation · Video tutorial (Bilibili) · 中文 · Examples

Showcase source · Getting started
Install and preview your first figure#
Install the VS Code extension or a platform VSIX. Platform packages include the native engine without Python, Rust or npm. For Remote SSH, choose the remote host's platform.
Save this as figure.lay in a working folder and run LayMesh: Open Preview:
page = canvas(size=(120mm,90mm), background="#ffffff")p = plot(size=(110mm,80mm), x=axis(label="Time (s)"), y=axis(label="Signal"))p.line(x=[0,1,2,3], y=[1,3,2,4], label="Experiment")p.legend(position="top_left")page.add(p, offset=(5mm,5mm))The current source build also supports add(p, offset=(5mm,5mm)) and a standalone canvas(...) declaration. If you omit the declaration, the first add(...) creates a transparent 160 × 90 mm canvas with a layout DPI of 300.
Geometry defaults to mm, typography and strokes to pt. Explicit lengths accept mm/cm/in/inch/pt/px. Layout px uses canvas.layout_dpi; export DPI independently controls raster density. See Units.
CLI, Python and Notebook#
Requires Python 3.10+. Platform wheels include the engine and formula fonts:
python -m pip install laymeshpython -m laymesh --versionlaymesh validate figure.laylaymesh render figure.lay -o figure.pdflaymesh render figure.lay -o figure.pngfrom laymesh import render_fileresult = render_file("figure.lay", output="figure.pdf")In Notebook, load %load_ext laymesh.ipython, then use %laymesh figure.lay or %%laymesh. NumPy/pandas bindings, Matplotlib Figure import and portable source/resource saving are supported. Installation · Python API · Notebook
Learn and look up#
| Task | Complete guide |
|---|---|
| Physical placement, anchors, groups and reuse | First layout · Layout and assets |
| Lines, scatter, errors, statistics, heatmaps and polar plots | First plot · Scientific plotting |
| Themes, libraries, typography, gradients and shadows | Style and animation libraries · Style manual · Style gallery |
| 97 effects, keyframes, timing and presentation | Animation manual · Effect catalog · Complete projects |
| Video, page audio and continuous background music | Video and audio · Runnable examples |
| Sequence pages and export a complete PDF | Documents |
| Text, formulas and artistic effects | Fonts · Formulas · Artistic text |
| SVG/PDF, raster, editable PPTX and MP4/GIF | Static exports · Animation exports |
.lay describes one page; .laydoc sequences multiple pages. Panels use explicit placement. PDF retains vector subjects with local raster blur effects. VS Code export asks for format/path only, defaults raster to 1200 DPI and TIFF to LZW, and puts other options in settings. Video export requires FFmpeg.
Themes hold repeated appearance; .lay holds size, placement and data. Explicit parameters override styles. Current-source manuals include new offline libraries and diagnostics requiring a build with those changes. Release notes describe published packages.
Documentation and development#
Getting started · Language reference · API · Architecture · Examples and recorded results
Source development requires Rust 1.93.1; build and release scripts require Python 3.11+. From the repository root:
cargo build --release --locked -p laymesh-clipython -m pip install -e './python'python -m laymesh render examples/basic.lay -o basic.pdfcargo test --workspace --lockedpython -m unittest discover -s python/tests -vFor direct native use, invoke target/release/laymesh (laymesh.exe on Windows). The release procedure covers wheel builds, audits, isolated installation checks and PyPI Trusted Publishing. Build the documentation site with python scripts/build-docs.py; the GitHub Pages workflow publishes it.
LayMesh is MIT licensed. Native dependencies, formula fonts and colormap data retain their own licenses; see third-party notices.