LayMesh
Reproducible scientific figures and precise physical layouts from readable code. Compose native plots, images, vector shapes, text and formulas in one editable .lay source; export SVG, PDF and PNG/JPEG/TIFF/WebP/BMP/GIF/ICO/PNM/TGA with a native Rust engine.
中文文档 · English documentation · Examples · Source
Install
Requires Python 3.10+. Version 0.3.1 adds configurable raster export. Install an uploaded release or a reviewed local platform wheel:
python -m pip install laymesh
python -m laymesh --version
Platform wheels bundle one native Rust executable and formula fonts. Rendering requires no Rust compiler, Node.js or TeX installation and downloads no engine or fonts. Body fonts come from the operating system or user-provided files; missing glyphs warn and display vector boxes. Supply font files with a layout for reproducible text across machines.
The standard installation includes NumPy, pandas, Matplotlib and IPython. Data bindings, Matplotlib Figure import and Jupyter magics are ready to use.
Wheel targets are Windows x64, macOS 14+ on Intel and Apple Silicon, and Linux x64 / arm64. Linux requires glibc at least as new as the wheel's manylinux_2_XX tag. Availability depends on uploaded wheels; Alpine/musl, 32-bit platforms and Windows ARM64 have no wheels. Plots are rendered by the native engine.
First figure: CLI
Save this complete source as figure.lay:
page = canvas(size=(120 mm, 90 mm), background="#ffffff")
p = plot(size=(110 mm, 80 mm),
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=(5 mm, 5 mm))
laymesh validate figure.lay
laymesh inspect figure.lay --json
laymesh render figure.lay -o figure.svg
laymesh render figure.lay -o figure.pdf
laymesh render figure.lay -o figure.png --dpi 300
python -m laymesh invokes the same CLI. Geometry defaults to mm; typography and line widths default to pt. Raster DPI changes output pixels while preserving physical dimensions. .lay is a restricted standalone language, separate from Python.
Image export options (0.3.1)
laymesh render figure.lay -o figure.jpg --dpi 300 --quality 95 --background "#ffffff"
laymesh render figure.lay -o figure.tif --dpi 600 --compression deflate
laymesh render figure.lay -o figure.webp --dpi 300 --webp-lossless false --quality 90 --webp-method 6
render_file and render_source accept dpi, quality, compression, background, webp_lossless, webp_method, webp_alpha_quality and webp_near_lossless. Notebook magics accept the corresponding CLI flags. Raster exports use 8-bit sRGB; PNG/JPEG/TIFF/BMP record DPI metadata. JPEG uses a matte; GIF has binary alpha; RGBA formats retain partial transparency. Export options.
Python API
from laymesh import render_source
source = '''
page = canvas(size=(120 mm, 90 mm), background="#ffffff")
p = plot(size=(110 mm, 80 mm),
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=(5 mm, 5 mm))
'''
result = render_source(source, output="python-figure.svg", save_source="python-figure.lay")
print(result.output)
Use render_file("figure.lay", output="figure.pdf") to render existing source. Pass Python variables via namespace={"values": values} and refer to them with an unquoted {{values}} placeholder in .lay. Lists, dictionaries, NumPy arrays and pandas DataFrames can feed native plots. Matplotlib Figures can be placed as image assets. Keep calculations in Python; placeholders accept variable names, not expressions.
save_source saves expanded source and a sibling .assets/ directory for independent CLI rendering. Preserve that directory and any referenced modules, stylesheets or fonts with the .lay file. Python API and data examples.
Jupyter
Install LayMesh in the active kernel's environment. First run:
%load_ext laymesh.ipython
values = [1, 3, 2, 4]
Then run this separate cell:
%%laymesh -o notebook.pdf --save-source notebook.lay
page = canvas(size=(120 mm, 90 mm))
p = plot(size=(110 mm, 80 mm))
p.line(x=[0, 1, 2, 3], y={{values}})
page.add(p, offset=(5 mm, 5 mm))
The magic displays an SVG preview and writes the requested export. %laymesh figure.lay -o figure.png --dpi 300 renders an existing file. Both magics support --warnings show|hide. Notebook guide.
Scope
LayMesh provides physical units, anchors, cropping, paths, reusable modules, LCSS styles and native scientific plots including statistical, polar and radar layers. Layouts are single-page; panels use explicit positioning. Finish plot layers and decorations before placing a chart. Fixed plot areas keep their physical dimensions; decoration overflow emits a warning. Language reference.
中文
LayMesh 用一个可编辑的 .lay 文件组织科研图表、图片、文字与公式,导出 SVG、PDF、PNG。需要 Python 3.10+;运行 python -m pip install laymesh 即可安装全部功能,包括 NumPy/pandas 数据绑定和 Matplotlib Figure 导入。平台 wheel 内置原生 Rust 引擎和公式字体,正文使用系统或用户字体。支持 laymesh 命令、Python API 和 Jupyter Magic;保存源码与资源后可独立重新导出。中文入门。
LayMesh is MIT licensed. Bundled native dependencies, formula fonts and colormap data retain their own license texts inside the installed package. _vendor/manifest.json records engine, platform and build hashes; _vendor/licenses/manifest.json records dependency license provenance.
Metadata
Release files for laymesh 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| laymesh-0.3.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| laymesh-0.3.1-py3-none-manylinux_2_35_x86_64.whl | Python 3 | none | Linux glibc 2.35+ x86-64 | Details |
| laymesh-0.3.1-py3-none-manylinux_2_35_aarch64.whl | Python 3 | none | Linux glibc 2.35+ ARM64 | Details |
| laymesh-0.3.1-py3-none-macosx_14_0_x86_64.whl | Python 3 | none | macOS 14.0+ x86-64 | Details |
| laymesh-0.3.1-py3-none-macosx_14_0_arm64.whl | Python 3 | none | macOS 14.0+ ARM64 | Details |
Total release size: 32.2 MB
Release files / laymesh-0.3.1-py3-none-win_amd64.whl
| Download URL | laymesh-0.3.1-py3-none-win_amd64.whl |
|---|---|
| Size | 6.5 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b19483b01714c2b0391fccf5fe1afaf48729ddcc10b60749f66a3afd57373f9b
|
|
BLAKE2b-256 checksum How to use checksums |
f2c792f8ac031423ee10c84b4dffec342dd7bab67b3acd26921d8d0155567e33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / laymesh-0.3.1-py3-none-manylinux_2_35_x86_64.whl
| Download URL | laymesh-0.3.1-py3-none-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | Linux glibc 2.35+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
0856bae595d9698fb3a7dcddf79f9a365832219aa61ee703a412cce815765564
|
|
BLAKE2b-256 checksum How to use checksums |
5646526c373e9395c9abeb63b5fd09b9472c2e978d1479bc8f334f1ba8967525
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / laymesh-0.3.1-py3-none-manylinux_2_35_aarch64.whl
| Download URL | laymesh-0.3.1-py3-none-manylinux_2_35_aarch64.whl |
|---|---|
| Size | 6.3 MB |
| Tags | Linux glibc 2.35+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
174bff9a5338bbd7dab534dfbc692e0204f6fd7da134d5c062ce6e0a793dc23a
|
|
BLAKE2b-256 checksum How to use checksums |
71c14dbb80fbf6234e5b0fa7126e022ad466ca35cc287f15226be9c3bc62dcf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / laymesh-0.3.1-py3-none-macosx_14_0_x86_64.whl
| Download URL | laymesh-0.3.1-py3-none-macosx_14_0_x86_64.whl |
|---|---|
| Size | 6.6 MB |
| Tags | Python 3 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
d26c905e657fe51ad39ebbfbf7a0f33354fa4e66c370f6e839caf6df4316e2ec
|
|
BLAKE2b-256 checksum How to use checksums |
74dace0d67f4d7142cbd17142cac3d582b5640c8e0e696b2d3fa1ede2305605a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / laymesh-0.3.1-py3-none-macosx_14_0_arm64.whl
| Download URL | laymesh-0.3.1-py3-none-macosx_14_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | Python 3 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aaf1fe4a6c5ca69c1b0e82fb989a971163802a26874dc439597154c92213eb22
|
|
BLAKE2b-256 checksum How to use checksums |
bc2d35be776939ebe2f72987ee52e74dc25fea65b33913bb875088dea5b62e74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency log