A comprehensive Python toolkit for extracting, aligning, and compositing Matplotlib SVG panels into publisher-ready figures with automatic scaling and alignment.
- 🎨 Multi-panel SVG extraction and assembly - Combine multiple Matplotlib figures into publication mosaics
- 📏 Automatic axis alignment - Align panels by x-axis label baseline or patch bottom
- 📐 Spine equalization - Normalize x/y-axis spine lengths across panels
- 📰 Publisher presets - IEEE Access, IEEE Trans, IEEE Proc, Nature journal sizing
- 🔲 Grid layout - Configurable rows, columns, gaps, and padding
- 🔤 Panel labeling - Automatic sequential labels (a, b, c, ...)
- 🎯 Content-aware bounding - Smart detection of axes, figure, and content boundaries
- Python 3.7+ (standard library only, no external dependencies)
git clone https://github.com/kshtjkumar/SVG_resizing_tool.git
cd SVG_resizing_tool
chmod +x run_example.sh
chmod +x process.shThe easiest way to use this tool is with the automated batch processing script:
- Add your SVG files to the
input/folder - Run the processing script:
./process.sh
- Get your processed files from the
output/folder
# Process all SVGs individually with default settings
./process.sh
# Process with publisher specifications
./process.sh --publisher ieee-trans --layout single
# Combine all SVGs into one composite figure with labels
./process.sh --combine --publisher nature --layout double --labels
# Interactive mode - prompts you for all options
./process.sh --interactive
# Full control with all options
./process.sh --combine --publisher ieee-trans --layout double --labels \
--max-per-row 2 --col-gap 10 --row-gap 10For more options, run ./process.sh --help
For advanced users who want full control over the processing pipeline:
python3 main.py output_panels/panel_*.svg \
--output final_figure.svg \
--outer-publisher ieee-trans \
--outer-layout double \
--max-per-row 2 \
--col-gap 0 \
--row-gap 0 \
--outer-pad 0 \
--add-panel-label \
--panel-label-first a \
--panel-label-font-size 8 \
--align \
--auto-match-scale \
--align-mode patch-bottom \
--align-xspine-equalize \
--align-yspine-equalizepython3 panel_frame_fit.py panel.svg \
--outer-publisher ieee-trans \
--outer-layout single \
--output framed.svgpython3 main.py <file1.svg> <file2.svg> ... --output <output.svg> [options]Publisher Mode Options:
--outer-publisher {ieee-access,ieee-trans,ieee-proc,nature}- Target journal--outer-layout {single,double,full}- Column layout--max-per-row N- Panels per row (default: 2)--col-gap MM- Horizontal gap between panels--row-gap MM- Vertical gap between rows--outer-pad MM- Outer frame padding
Alignment Options:
--align- Enable post-processing alignment--align-mode {xlabel,patch-bottom}- Alignment target--align-xspine-equalize- Match x-axis spine lengths--align-yspine-equalize- Match y-axis spine lengths--auto-match-scale- Normalize scales if inputs differ
Labeling:
--add-panel-label- Add sequential labels--panel-label-first a- Starting label (default: 'a')--panel-label-font-size PX- Label font size
python3 panel_frame_fit.py panel.svg \
--outer-publisher ieee-trans \
--outer-layout single \
--output framed.svg# List available panels
python3 extras/extract_panel_svg_og.py mosaic.svg --list
# Extract by letter
python3 extras/extract_panel_svg_og.py mosaic.svg --panel a --output panel_a.svgSee run_example.sh for a complete working example.
main.py- Main mosaic assembly scriptalign_axes.py- Post-processing alignment utilitypanel_frame_fit.py- Single/multi-panel framing toolextras/extract_panel_svg_og.py- Panel extraction from composite SVGsrun_example.sh- Demo script
- Transform matrices with nonzero skew (b or c terms) may produce approximate bounding boxes in extraction mode
- Alignment requires Matplotlib-style SVG structure (axes groups with matplotlib.axis_* children)
Validate all scripts compile correctly:
python3 -m py_compile main.py align_axes.py panel_frame_fit.py extras/extract_panel_svg_og.pyContributions welcome! Please ensure:
- All scripts pass
python3 -m py_compile <script.py> - Test end-to-end pipeline with sample SVGs
- Document any new publisher presets or alignment modes
MIT License
If you use this tool in your research, please cite:
@software{svg_resizing_tool,
author = {Kumar, Kshtij},
title = {SVG Resizing Tool: Publisher-ready Matplotlib figure composition},
year = {2025},
url = {https://github.com/kshtjkumar/SVG_resizing_tool}
}
Designed for reproducible scientific figure preparation with precise control over panel layout and publisher specifications.