sciglyph
Publication-quality scientific illustration in pure matplotlib — no BioRender, no Illustrator.
Overview figures and architecture diagrams are usually drawn by hand in a subscription tool. That makes them pretty, but also unreproducible: you cannot diff them, you cannot regenerate them when the numbers change, and you cannot put them under version control.
sciglyph gives you the primitives to draw the same figures as code.
Both figures above are generated by the scripts in examples/ — nothing was touched by hand. The content is synthetic; swap in your own numbers and the layout carries over.
Why
| subscription tools | sciglyph |
|
|---|---|---|
| Reproducible | ✗ manual pixel-pushing | ✓ a script |
| Version control | ✗ binary blobs | ✓ diffable source |
| Data-driven | ✗ retype every number | ✓ read straight from your results |
| Vector output | ~ depends on export | ✓ PDF/SVG with editable text |
| Cost | subscription | free, MIT |
Install
pip install git+https://github.com/GuoCheng24/sciglyph
Only matplotlib and numpy. Nothing else.
Not on PyPI yet, so the git URL above is the install line that works today.
When it lands, pip install sciglyph will too.
Quick start
import matplotlib.pyplot as plt
from sciglyph import bio, set_canvas, report, RC
plt.rcParams.update(RC)
fig = plt.figure(figsize=(7.2, 3.0), dpi=300)
ax = fig.add_axes([0, 0, 1, 1]); ax.set_xlim(0, 1); ax.set_ylim(0, 1); ax.axis("off")
set_canvas(fig) # required on non-square canvases
bio.person(ax, .08, .55, s=.30)
bio.dna(ax, .25, .55, w=.05, h=.45, n=2)
bio.cell(ax, .42, .55, r=.06, seed=1)
bio.seq_logo(ax, .60, .40, [("A", .6), ("C", .9), ("G", .4), ("T", .7)], w=.03)
report(fig, ax) # catch text collisions before saving
fig.savefig("figure.pdf", bbox_inches="tight")
Run the full examples:
python examples/overview_figure.py # -> gallery/overview_figure.png
python examples/architecture.py # -> gallery/architecture.png
What's included
sciglyph.bio — glyphs for Nature/Science-style overview figures:
person (cohorts) · dna · cell · lipid · metabolite ·
nucleosome_chain · umap_layer (the stacked atlas look) ·
seq_logo (information-scaled letters, no logomaker needed) ·
stacked_planes · rbox · arr
sciglyph.arch — glyphs for architecture diagrams:
cuboid / feature_stack (3-D feature blocks) · trapezoid (encoders) ·
module_stack (Conv|BN|ReLU bars) · dashed_group (the (a)/(b)/(c)
language) · flow · op_circle · snowflake (frozen backbone) ·
image_thumb · embedding_space (contrastive panels) · loss_tag · bracket
sciglyph.layout — pre-flight collision detection.
Catching layout bugs before you save
When a figure breaks, it is almost never the artwork — it is the layout.
report() uses the real rendered bounding boxes to find overlapping text, so
you do not have to hunt for it by eye:
report(fig, ax)
# [sciglyph.layout] 36 text objects
# ! 'CD4 Treg/-FOXP3' x 'SMR' overlap 92%
It also works from the command line on any script that exposes fig and ax:
python -m sciglyph.layout my_figure.py
It checks three things, each of which shipped a broken figure before it existed:
| check | what it catches |
|---|---|
| text overlap | two labels drawn over each other |
| artwork overlap | a row of boxes laid out slightly too wide, so each one covers its neighbour — the strings may not overlap at all, so text-level checks miss it entirely |
| missing glyphs | a character the font cannot draw, rendered as an empty box. Symbols typed as literals (✓, ❄) are the usual casualty |
Two kinds of overlap are deliberately not reported, because they are the layout working: a panel containing its contents, and an unfilled dashed shape — a ring drawn around the thing it annotates.
These are geometric checks. Whether the figure actually reads well still needs your eyes.
Notes from actually shipping these figures
- Call
set_canvas(fig). In[0,1]coordinates a "circle" isr·Wwide andr·Htall. On a 12×3 canvas, every circle becomes a rugby ball. - Anchor arrows to what
feature_stackreturns, not to hard-coded coordinates — otherwise changing the number of blocks silently breaks them. - Never put symbol codepoints in figure text.
❄(U+2744) is missing from most sans fonts and renders as a tofu box. Draw it (arch.snowflake). - Overlapping translucent fills blend into one muddy colour. Keep the fill
under
alpha=0.15, stroke each curve, and offset the peaks. Tuning alpha alone will not save you. - Fonts: Arial/Helvetica are often absent on Linux.
RCfalls back to Liberation Sans (metric-compatible with Arial) and setspdf.fonttype=42so text stays editable in the PDF — a hard requirement at most journals. - Don't move elements toward whitespace. Whitespace relocates, it does not disappear. Decide which row an element belongs to, move it as a group, then verify with the quadrant ink distribution.
Honest scope
This gets you clean flat schematics combined with data panels — the register of a Nature/Science overview figure or a TPAMI architecture diagram. It will not reproduce hand-drawn illustration (shaded organs, textured cells, gradients). For that, embed a CC-BY asset and cite it rather than fake it.
License
MIT © Guo Cheng
关于那行 star 提示
调用 report() 时,sciglyph 会在第 5 次和第 25 次往 stderr 写一行,提一句这个仓库在哪。一辈子只有这两次,此外再不出声。
它不会出现在:管道或重定向里(stderr 不是终端就直接返回,连计数文件都不建)、CI 环境里(CI / GITHUB_ACTIONS)。它写的是 stderr 而非 stdout,所以不会污染你的数据输出;它包在 try/finally 里且吞掉自身所有异常,不会改变退出码,也不会影响结果。
永久关掉:
export SCIGLYPH_NO_NUDGE=1
计数存在 $XDG_STATE_HOME/sciglyph/usage.json(默认 ~/.local/state/sciglyph/usage.json),删掉即重置。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sciglyph-0.1.0.tar.gz.
File metadata
- Download URL: sciglyph-0.1.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
888e3cc66ce3a7e3c8e7c4965d39c6110b14d8fa15641fe124abfcedf086f709
|
|
| MD5 |
0e64d21182e1f95ac39cf9c9522bee35
|
|
| BLAKE2b-256 |
d27f81d31ab063951e4b07b6847d154df512ed10d11084781329ad9d3b9acb08
|
File details
Details for the file sciglyph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sciglyph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfd2751834d27dfde4755166423d89b37571392a4f74fe678ba4d5561bc83f3c
|
|
| MD5 |
59fb0e022d10d6c8ba9ab0a85b813964
|
|
| BLAKE2b-256 |
a8f966f316059709513643cdfc53beb5ee96a9b19154779588e71d4e88503519
|