Compose SVG figures and LaTeX equations into a panel template
Project description
pc — Panel Compiler
Compose scientific figures from SVG plots, PDF figures, and LaTeX equations into a single SVG or PDF panel. This is intended for the case that these subfigures are generated by scripts and you automatically want to keep your panels up to date.
Define a panel template in Inkscape with named group (<g>) or rectangle (<rect>) placeholders (set via the layer/group label field), then write a small YAML config that maps each label to an SVG file, PDF, or a LaTeX string. pc scales each figure to fit its placeholder and writes the compiled panel.
It is often convenient to let pc overwrite the old panel (labels are preserved for repeated execution).
Example
An example is given in example.
Assume you would like to create a panel with 3 subfigures.
Two are figures created via python code, and one contains a LaTeX formula.
We start from the panel template example/panel.svg that was created in Inkscape.
Here, the template is simple and contains only three rect placeholders, each of which has set its label (via Inkscape) set to one of: formula, logistic, and logistic_log.
This is the panel:
The python script that generates the subfigures is example/subfigures.py with the following
subfigures being generated:
logistic.svg |
logistic_log.svg |
|---|---|
Next we prepared a configuration example/pc.yaml that tells the panel-compiler how to
compile the panel:
panel: panel.svg
output:
- out.svg
- panel.pdf
formula:
tex: $\frac{dN}{dt} = rN\!\left(1 - \frac{N}{K}\right)$
size: 10pt
logistic:
file: logistic.svg
fit: contain
logistic_log:
file: logistic_log.svg
fit: contain
The panel is finally compiled via:
cd example
python subfigures.py
pc pc.yaml
Resulting in the generation of example/out.svg:
Installation
From PyPI:
uv tool install panel-compiler
or with pip:
pip install panel-compiler
From the repository:
uv tool install git+https://github.com/mfuegger/pc.git
or with pip:
pip install git+https://github.com/mfuegger/pc.git
For LaTeX rendering, pdflatex must be on your PATH. For PDF figures and PDF output, pdf2svg and inkscape must be on your PATH. On macOS: brew install pdf2svg.
Usage
pc [config.yaml]
| Argument | Default | Description |
|---|---|---|
config.yaml |
pc.yaml |
YAML config (see below) |
The output path is taken from the output key in the config. If omitted, it defaults to the config filename with .svg extension (e.g. pc.yaml → pc.svg).
Config format
Single panel
panel: panel.svg # required — path to the panel SVG, relative to this config file
output: out.svg # optional — defaults to <config-stem>.svg if omitted
output can also be a list to produce multiple formats in one run:
output:
- out.svg
- out.pdf
Each remaining key is a label that must match an element in the panel SVG. pc looks it up by inkscape:label first, then label, then id. The element can be a <g> group or a <rect> placeholder — a <rect> is automatically replaced by a <g> positioned at the rect's x/y.
Figure entry (SVG or PDF)
plot:
file: results.svg # path relative to this config file; .svg or .pdf (alias: svg:)
fit: contain # contain | height | width (default: contain)
width: 200 # optional — override the target width (SVG user units)
height: 100 # optional — override the target height (SVG user units)
Fit strategies:
contain— scale uniformly to fit within the placeholder box (default)height— scale to match the placeholder height exactlywidth— scale to match the placeholder width exactly
Target dimensions come from width/height attributes on the group element in the panel SVG. The config width/height are used as a fallback when the group has no such attributes.
PDF files are converted via pdf2svg before embedding.
LaTeX entry
label:
tex: $y = \sin(x)$ # any LaTeX — math mode, text, amsmath, …
size: 12pt # font size (default: 10pt); scales the rendered output
Rendered via pdflatex + inkscape. No fit scaling — the output is sized by size alone.
Shorthand
A plain string value is treated as an SVG file path with fit: contain:
other: path/to/fig.svg
Multiple panels
Use a YAML list; each entry must have its own output:
- panel: panel1.svg
output: out1.svg
plot:
file: results.svg
- panel: panel2.svg
output:
- out2.svg
- out2.pdf
label:
tex: $E = mc^2$
size: 12pt
License
Apache 2.0 — see LICENSE.
Project details
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 panel_compiler-0.1.4.tar.gz.
File metadata
- Download URL: panel_compiler-0.1.4.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2156ca508619db6d6cce669dbcc6156ea65b5975ee155e4385e7a3cd0866d641
|
|
| MD5 |
3301e5cacab9b6b9a84077147e07b570
|
|
| BLAKE2b-256 |
b24e5e92c5799af05ad3e22d4421048074f4ad242a2bf0b6cfe58dc203d3a20a
|
Provenance
The following attestation bundles were made for panel_compiler-0.1.4.tar.gz:
Publisher:
publish.yml on BioDisCo/panel-compiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
panel_compiler-0.1.4.tar.gz -
Subject digest:
2156ca508619db6d6cce669dbcc6156ea65b5975ee155e4385e7a3cd0866d641 - Sigstore transparency entry: 1199806346
- Sigstore integration time:
-
Permalink:
BioDisCo/panel-compiler@53e6bfb73b0abd40ea2bc31efab5a301ac74f3d5 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/BioDisCo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@53e6bfb73b0abd40ea2bc31efab5a301ac74f3d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file panel_compiler-0.1.4-py3-none-any.whl.
File metadata
- Download URL: panel_compiler-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
610ba968acc1b8e83c8986b413c40f05b3c264f8a0ef14bfca05be9363fae834
|
|
| MD5 |
72bc3412395e45e071b91f9384c622b1
|
|
| BLAKE2b-256 |
4a11794a22387dc031c6630ea46658e35367c83ca3ac2652609bb093d401fad9
|
Provenance
The following attestation bundles were made for panel_compiler-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on BioDisCo/panel-compiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
panel_compiler-0.1.4-py3-none-any.whl -
Subject digest:
610ba968acc1b8e83c8986b413c40f05b3c264f8a0ef14bfca05be9363fae834 - Sigstore transparency entry: 1199806349
- Sigstore integration time:
-
Permalink:
BioDisCo/panel-compiler@53e6bfb73b0abd40ea2bc31efab5a301ac74f3d5 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/BioDisCo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@53e6bfb73b0abd40ea2bc31efab5a301ac74f3d5 -
Trigger Event:
push
-
Statement type: