Compose raster and vector images to publication-ready figures for scientific journals
Project description
svgsubfig
A python package for swift arrangement of raster images and vector graphics into a single figure based on SVG.
This package is focussed on the preparation of high quality figures that consist of several subimages, both vector and raster graphics, for publication in scientific journals. A label is inserted below each subimage, e.g. (a), (b), ...
Font family, size and gaps can be adjusted based on a JSON configuration. An example figure created with svgsubfig could look like this:
Basic usage
Installation
svgsubfig can be installed using pip:
pip install svgsubfig
Configuration
Create a JSON configuration file with the following structure, use relative filenames for the individual (sub-)images (the directory of the config file acts as base directory).
{
"gap-between": 5,
"gap-label": 3,
"width": 150,
"font-size": 9,
"font-family": "Arial, Helvetica, sans-serif",
"images": [
"img/dog.jpeg",
"img/population.svg"
],
"description": [
"A dog.",
"The dogs population."
]
}
Following keys are available for the config file:
description: Text to be added after each label.font-family: Typeface used in the SVG file for text.font-size: Size of the labeling of the images in pt.gab-between: Spacing between the subimages in mm.gap-label: Spacing between labels and lower boundary of the images in mm.images: Array of file paths of the images to include into the figure.index-offset: Offset of the first subimage index, e.g. ifindex-offset = 3, the first label will be(d)width: Width of the figure in mm.
To use automatic conversion of the created SVG figure file into PDF and PNG file formats, Inkscape needs to be installed and accessible on PATH.
Figure composition
To create the final figure using the JSON configuration, a small svgsubfig command line utility can be used, but also scripting is possible.
Command line utility
To use the svgsubfig module to create the final figure file, use following command in your terminal:
python -m svgsubfig [--noconvert] CONFIG_PATH
Replace CONFIG_PATH with the path of the JSON config file. Option --noconvert prevents conversion of the created SVG into PDF and PNG with Inkscape, which is useful in case Inkscape is not installed, or manual edits on the created SVG file are necessary.
Script
import svgsubfig.utility as util
from svgsubfig import SVGSubFigure
from pathlib import Path
pth_config = Path("figure.json")
pth_svg = pth_config.with_suffix(".svg")
fig = SVGSubFigure.from_json(pth_config)
fig.save(pth_svg)
util.convert_svg(pth_svg)
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 svgsubfig-0.2.0.tar.gz.
File metadata
- Download URL: svgsubfig-0.2.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c5ea090581f63d749c87b3809818edd3734c352adf4fa0e7ca0310534fa3bd0
|
|
| MD5 |
72a9d942d77445259c5cae002c0d6d8d
|
|
| BLAKE2b-256 |
995cfffe4b8083376de539c4f3635986bbde25942e402874c40cd95bc95afee5
|
File details
Details for the file svgsubfig-0.2.0-py3-none-any.whl.
File metadata
- Download URL: svgsubfig-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11d82fad95729311b8f9035ad622313bd7d77527809534de20edb67f5c7bde56
|
|
| MD5 |
3a7b4b5b611de038cb71cdc5bf505a66
|
|
| BLAKE2b-256 |
bd6afde297b16b1f4d806b7af76b5f2656f7924d22aed35fc99872ca747458a6
|