Interactive layout designer for multi-panel scientific figures
Project description
AxisBlueprint
AxisBlueprint is a lightweight Python toolbox for interactively designing multi-panel scientific figure layouts. Built with Tkinter, it provides a drag-and-drop GUI for arranging axis boxes on a grid, then exports Matplotlib code or renders the layout directly.
Installation
pip install axisblueprint
For FigureFromLayout and generated Matplotlib previews, install the optional plotting dependency:
pip install "axisblueprint[plot]"
Requirements
- Python 3.8+
- Tkinter (usually included with Python; on Ubuntu/Debian:
sudo apt install python3-tk) - Matplotlib (optional, for
[plot]extra)
Quick Start
In a Jupyter Notebook (with Tkinter event loop enabled):
%gui tk
from axisblueprint import BlueprintBuilder
BlueprintBuilder()
Or from the command line:
axisblueprint
Features
- Interactive Layout Design — Create, duplicate, and remove axis boxes on an A4 canvas with a half-centimeter grid overlay.
- Move & Resize Modes — Drag boxes to reposition them, or resize from the top-left corner.
- Snap-to-Grid — Optimize your layout by snapping boxes to the nearest half-centimeter.
- Save, Save As & Load — Save overwrites the current file; Save As writes to a new location; Load opens any
.jsonlayout. - Default Templates — Save your current layout as the startup default (including canvas size and margins), loaded automatically on next launch.
- Settings Window — Configure default canvas size, margins, grid spacing, and templates directory via File → Settings.
- Matplotlib Code Generation — Automatically generate Python code that recreates your layout.
- FigureFromLayout — Load saved layouts as Matplotlib figures programmatically.
- Undo/Redo — Full undo/redo support via the Edit menu or Ctrl+Z / Ctrl+Y.
- Keyboard Shortcuts — Delete, Ctrl+S, arrow keys for nudging.
- Multi-Select — Shift+click or rubber-band select; align/distribute operations use the selection.
- Layout Aids — Snap-to-guides while moving, overlap detection (orange outline), 90° rotation.
- Per-Side Margins — Configure left, right, top, and bottom margins independently.
- Open Recent — Track recently opened layouts.
- Auto Panel Labels — Automatically assign sequential labels (a., b., c., ...) to panels.
Usage
GUI
- Select a box: Left-click on an axis box to select it (highlighted in red).
- Choose Interaction Mode: Use the radio buttons on the right panel for Move or Resize.
- Add boxes: Click the New Panel button.
- Deselect: Right-click anywhere on the canvas.
- Optimize: Click Optimize to snap all boxes to the nearest half-centimeter.
- Save/Load: Use File → Save (Ctrl+S) to overwrite the current file, File → Save As... to choose a new location, or File → Load to open a saved layout.
- Default Template: Use File → Save as Default Template to set the current layout (including canvas size and margins) as the startup default.
- Settings: Use File → Settings to configure default canvas size, margins, grid spacing, and templates directory.
- Generate Code: Click Generate Code to create a Matplotlib code snippet.
Programmatic: FigureFromLayout
Once you have a layout saved, generate it directly in Python:
from axisblueprint import FigureFromLayout
fig, axes = FigureFromLayout("default")
Load from a custom directory:
fig, axes = FigureFromLayout("my_layout", "/path/to/my/layouts")
Returns a matplotlib.Figure and a list of matplotlib.axes.Axes objects.
Layout File Format
Layouts are saved as JSON files. The format includes versioning for forward compatibility:
{
"version": 1,
"canvas": {
"width_cm": 21.0,
"height_cm": 29.7,
"margins": { "left": 1.0, "right": 1.0, "top": 1.0, "bottom": 1.0 }
},
"boxes": [
{ "x": 1.0, "y": 1.0, "width": 9.25, "height": 6.675, "panel_label": "A" }
]
}
API Reference
AxisBox(x, y, width, height, panel_label="")
A single panel in the layout. Coordinates and dimensions are in centimeters.
BlueprintBuilder()
Launch the Tkinter GUI.
LayoutDesigner(parent)
Embed the layout designer in an existing Tkinter application.
figure_from_layout(layout_name, layouts_dir=None)
Load a saved layout and return a Matplotlib figure with axes.
generate_matplotlib_code(boxes, page_width_cm, page_height_cm)
Generate a Python script string for the given layout.
Configuration
- Settings:
~/.config/axisblueprint/settings.json— default canvas size, margins, grid spacing, and templates directory (editable via File → Settings in the GUI). - Templates directory:
~/.config/axisblueprint/templates/— contains saved layouts anddefault.json(loaded on startup). - Override: Set the
AXISBLUEPRINT_TEMPLATES_DIRenvironment variable to use a custom templates directory. - Recent layouts:
~/.config/axisblueprint/recent_layouts.json
Contributing
Contributions are welcome! Please open issues or submit pull requests on GitHub.
Development
Clone and install in editable mode:
git clone https://github.com/NikDrummond/AxisBlueprint.git
cd AxisBlueprint
pip install -e ".[plot]"
Run tests:
python -m pytest tests/
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 axisblueprint-0.2.0.tar.gz.
File metadata
- Download URL: axisblueprint-0.2.0.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f870425a3b9ee7ac537bb4aedb2f62be589d179925e9d49d1819bf0e8a531fc
|
|
| MD5 |
fa33c8cef27aabb3dff01dc4ed25380d
|
|
| BLAKE2b-256 |
7735a6bc2da2cfbbbaa0293598d74c80106643baa6ccf5372f4c2b305adaa5f8
|
File details
Details for the file axisblueprint-0.2.0-py3-none-any.whl.
File metadata
- Download URL: axisblueprint-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c004229d1d9512e1d619cd7fb100fd94eee5a4e8063d0c8dfff8fdf532c06acb
|
|
| MD5 |
ed68eba057910ae61235185a0f9976a6
|
|
| BLAKE2b-256 |
360a57eaab9d909533b0e52918e7ea7fe4dcd9e275a35d0adf1801d43b91a418
|