panelist 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- panelist-0.1.0/LICENSE +21 -0
- panelist-0.1.0/PKG-INFO +361 -0
- panelist-0.1.0/README.md +337 -0
- panelist-0.1.0/pyproject.toml +53 -0
- panelist-0.1.0/setup.cfg +4 -0
- panelist-0.1.0/src/panelist/__init__.py +3 -0
- panelist-0.1.0/src/panelist/adapters.py +218 -0
- panelist-0.1.0/src/panelist/apply.py +48 -0
- panelist-0.1.0/src/panelist/canvas_dist/canvas.js +8183 -0
- panelist-0.1.0/src/panelist/canvas_dist/index.html +1755 -0
- panelist-0.1.0/src/panelist/cli.py +399 -0
- panelist-0.1.0/src/panelist/compiler.py +565 -0
- panelist-0.1.0/src/panelist/diff.py +166 -0
- panelist-0.1.0/src/panelist/document.py +1544 -0
- panelist-0.1.0/src/panelist/editor_window.py +748 -0
- panelist-0.1.0/src/panelist/edits.py +912 -0
- panelist-0.1.0/src/panelist/export.py +130 -0
- panelist-0.1.0/src/panelist/files.py +17 -0
- panelist-0.1.0/src/panelist/inventory.py +93 -0
- panelist-0.1.0/src/panelist/layout_runtime.py +1617 -0
- panelist-0.1.0/src/panelist/layouts.py +150 -0
- panelist-0.1.0/src/panelist/log.py +76 -0
- panelist-0.1.0/src/panelist/palettes.py +261 -0
- panelist-0.1.0/src/panelist/paths.py +10 -0
- panelist-0.1.0/src/panelist/plots.py +370 -0
- panelist-0.1.0/src/panelist/preflight.py +320 -0
- panelist-0.1.0/src/panelist/presets/elsevier.json +75 -0
- panelist-0.1.0/src/panelist/presets/nature.json +80 -0
- panelist-0.1.0/src/panelist/presets/panelist.json +30 -0
- panelist-0.1.0/src/panelist/presets/plos-one.json +76 -0
- panelist-0.1.0/src/panelist/publish.py +172 -0
- panelist-0.1.0/src/panelist/render.py +870 -0
- panelist-0.1.0/src/panelist/schema/preset.schema.json +579 -0
- panelist-0.1.0/src/panelist/serve.py +482 -0
- panelist-0.1.0/src/panelist/styles.py +538 -0
- panelist-0.1.0/src/panelist/units.py +19 -0
- panelist-0.1.0/src/panelist.egg-info/PKG-INFO +361 -0
- panelist-0.1.0/src/panelist.egg-info/SOURCES.txt +83 -0
- panelist-0.1.0/src/panelist.egg-info/dependency_links.txt +1 -0
- panelist-0.1.0/src/panelist.egg-info/entry_points.txt +2 -0
- panelist-0.1.0/src/panelist.egg-info/requires.txt +4 -0
- panelist-0.1.0/src/panelist.egg-info/top_level.txt +1 -0
- panelist-0.1.0/tests/test_adapter_helpers.py +82 -0
- panelist-0.1.0/tests/test_annotations.py +376 -0
- panelist-0.1.0/tests/test_axis_scale.py +110 -0
- panelist-0.1.0/tests/test_canvas_parity.py +52 -0
- panelist-0.1.0/tests/test_cli_edit.py +17 -0
- panelist-0.1.0/tests/test_colormap.py +87 -0
- panelist-0.1.0/tests/test_compile_folder.py +65 -0
- panelist-0.1.0/tests/test_compile_safety.py +135 -0
- panelist-0.1.0/tests/test_diff.py +137 -0
- panelist-0.1.0/tests/test_edits.py +332 -0
- panelist-0.1.0/tests/test_engine.py +255 -0
- panelist-0.1.0/tests/test_export.py +112 -0
- panelist-0.1.0/tests/test_figure_texts.py +137 -0
- panelist-0.1.0/tests/test_fresh_run.py +120 -0
- panelist-0.1.0/tests/test_grid_regressions.py +138 -0
- panelist-0.1.0/tests/test_hidden.py +249 -0
- panelist-0.1.0/tests/test_inset_connectors.py +136 -0
- panelist-0.1.0/tests/test_invariants.py +132 -0
- panelist-0.1.0/tests/test_layouts.py +134 -0
- panelist-0.1.0/tests/test_legends.py +145 -0
- panelist-0.1.0/tests/test_log.py +67 -0
- panelist-0.1.0/tests/test_look.py +482 -0
- panelist-0.1.0/tests/test_nested_groups.py +188 -0
- panelist-0.1.0/tests/test_page_subfigures.py +50 -0
- panelist-0.1.0/tests/test_palettes.py +82 -0
- panelist-0.1.0/tests/test_plots.py +249 -0
- panelist-0.1.0/tests/test_preflight.py +105 -0
- panelist-0.1.0/tests/test_preset_files.py +117 -0
- panelist-0.1.0/tests/test_preset_reference.py +131 -0
- panelist-0.1.0/tests/test_regressions.py +113 -0
- panelist-0.1.0/tests/test_render.py +486 -0
- panelist-0.1.0/tests/test_script_state_returns.py +205 -0
- panelist-0.1.0/tests/test_series.py +148 -0
- panelist-0.1.0/tests/test_serve.py +56 -0
- panelist-0.1.0/tests/test_service_edges.py +239 -0
- panelist-0.1.0/tests/test_shared_runtime.py +140 -0
- panelist-0.1.0/tests/test_styles.py +501 -0
- panelist-0.1.0/tests/test_subfigures.py +68 -0
- panelist-0.1.0/tests/test_testbed.py +160 -0
- panelist-0.1.0/tests/test_text_props.py +171 -0
- panelist-0.1.0/tests/test_ticks.py +210 -0
- panelist-0.1.0/tests/test_views.py +139 -0
- panelist-0.1.0/tests/test_zorder.py +122 -0
panelist-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrea Ivan Costantino
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
panelist-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: panelist
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Layout documents for multi-panel matplotlib figures, compiled to plain matplotlib.
|
|
5
|
+
Author: Andrea Ivan Costantino
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/costantinoai/panelist
|
|
8
|
+
Project-URL: Repository, https://github.com/costantinoai/panelist
|
|
9
|
+
Project-URL: Issues, https://github.com/costantinoai/panelist/issues
|
|
10
|
+
Keywords: matplotlib,figure,layout,multi-panel,scientific figures,publication
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Framework :: Matplotlib
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: matplotlib<3.12,>=3.10
|
|
21
|
+
Provides-Extra: editor
|
|
22
|
+
Requires-Dist: PySide6>=6.11; extra == "editor"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
|
|
27
|
+
# panelist
|
|
28
|
+
|
|
29
|
+
**Arrange multi-panel matplotlib figures with the mouse. Keep the arrangement in a layout file. Publish with plain matplotlib.**
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
[Why](#why-panelist) · [How it works](#how-it-works) · [Features](#features) · [Screenshots](#screenshots) · [Install](#install) · [Usage](#usage) · [Related projects](#related-projects)
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
<table>
|
|
41
|
+
<tr>
|
|
42
|
+
<td width="50%">
|
|
43
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/video_journal.gif" alt="An arrow and a text box are drawn, a plot is cropped, and the page is set to Nature's single column: the grid is rearranged into one column"><br>
|
|
44
|
+
<sub><b>Annotate, crop, fit a journal's column:</b> an arrow and a text box, a crop, then Nature's 89 mm page, explained and previewed first.</sub>
|
|
45
|
+
</td>
|
|
46
|
+
<td width="50%">
|
|
47
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/video_look.gif" alt="The figure is despined and recoloured, one panel gets its own colours, and the script is rerun on new data with the same layout"><br>
|
|
48
|
+
<sub><b>The figure's look:</b> despine, a palette, lines and ticks, one panel's own colours; then new data, the same layout and look.</sub>
|
|
49
|
+
</td>
|
|
50
|
+
</tr>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
## Why panelist
|
|
56
|
+
|
|
57
|
+
A figure for a paper is usually several plots on one page. Each plot comes from code, but the page has its own rules: the journal's column width in millimetres, axes that line up, equal gaps, the same font size for every tick label, a bold letter on each panel.
|
|
58
|
+
|
|
59
|
+
In matplotlib today there are two ways to get there, and both are slow:
|
|
60
|
+
|
|
61
|
+
- **Guess numbers in code.** Tune `fig.add_axes`, gridspec ratios and `subplots_adjust`, rerun the script, look, and guess again.
|
|
62
|
+
- **Fix the export by hand.** Open the PDF in Illustrator or Inkscape and move things around. Every time the data change, the figure is regenerated and the manual work starts over.
|
|
63
|
+
|
|
64
|
+
panelist lets you place the panels by eye on the rendered figure, saves the result as data, and replays it on every run of your script.
|
|
65
|
+
|
|
66
|
+
## How it works
|
|
67
|
+
|
|
68
|
+
1. **Open** the figure your script already draws in the panelist editor.
|
|
69
|
+
2. **Arrange** it on a millimetre page: move and align panels, put them in layout grids, and set the size, weight and font of every kind of text.
|
|
70
|
+
3. **Save.** The arrangement is stored in a layout file next to your code (`fig.layout.json`).
|
|
71
|
+
4. **Compile.** panelist turns the layout file into a small Python module (`fig_layout.py`) that imports only matplotlib and the standard library's `warnings`. It writes only over a module it generated earlier, never over your script or any other file.
|
|
72
|
+
5. **Apply** it from your script with one call:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from fig_layout import apply_layout
|
|
76
|
+
|
|
77
|
+
apply_layout(fig, targets={"a": ax_a, "b": ax_b})
|
|
78
|
+
fig.savefig("fig.pdf")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
When the data change, rerun the script and the layout comes back exactly as it was. Your plotting code is never edited, and the published figure does not need panelist installed.
|
|
82
|
+
|
|
83
|
+
## Features
|
|
84
|
+
|
|
85
|
+
Everything below is stored in the layout file. Your script is never edited, and Reset gives back what it drew.
|
|
86
|
+
|
|
87
|
+
### The page
|
|
88
|
+
|
|
89
|
+
| | |
|
|
90
|
+
|---|---|
|
|
91
|
+
| **Journal widths** | The page is in millimetres. One click sets the single, 1.5 or double column width of Nature, Elsevier or PLOS ONE (sizes read from their guides), or of your own preset. |
|
|
92
|
+
| **A new page size, previewed** | When panels no longer fit, the grid is rearranged into fewer columns and the plots keep their size. Scaling the plots is offered only when that is not enough. You see what will change before anything moves. |
|
|
93
|
+
| **Trim** | Trim the page to its content in one click. |
|
|
94
|
+
| **Check for a journal** | Page width and depth, text too small or too big, fonts that are not installed, anything off the page. Each problem links to what to select. |
|
|
95
|
+
|
|
96
|
+
### Placing panels
|
|
97
|
+
|
|
98
|
+
| | |
|
|
99
|
+
|---|---|
|
|
100
|
+
| **Direct editing** | Drag panels, resize plots by their handles, nudge by 0.1 mm with the arrow keys. Edges, centres, plot frames and equal gaps snap, with guides. |
|
|
101
|
+
| **Arrange and group** | Align, distribute with equal gaps, match widths or heights. Group panels and nest groups. |
|
|
102
|
+
| **Layout grids** | Put panels into grid cells, drag grid lines, add rows or columns, attach a second grid to an edge. A grid never resizes a panel: a change that would not fit is refused, and the editor says why. |
|
|
103
|
+
| **Panel, plot, element** | Double-click a panel to work on its plots, each with its colorbar and title. Double-click a plot to reach its single elements; Esc goes back. |
|
|
104
|
+
| **Crop** | Crop a plot like a photo (C): it gets smaller at the same data scale. Log axes and images too. |
|
|
105
|
+
| **In front, behind** | Bring a plot, a text, a legend or a shape to the front or send it back (Ctrl+] and Ctrl+[). |
|
|
106
|
+
|
|
107
|
+
### Text and annotations
|
|
108
|
+
|
|
109
|
+
| | |
|
|
110
|
+
|---|---|
|
|
111
|
+
| **Text styles** | Size, bold and italic for each kind of text (panel letters, titles, axis labels, tick labels, legends, annotations), and one font for all of it. A preset applies a journal's rules in one click. |
|
|
112
|
+
| **Edit any text** | Double-click a title, an axis label or any figure text and type. |
|
|
113
|
+
| **Colour and angle** | Colour any text; rotate a text or one axis's tick labels. |
|
|
114
|
+
| **Panel letters** | One command adds a, b, c… in reading order, at each panel's top-left corner. |
|
|
115
|
+
| **Shapes and text boxes** | Draw lines, arrows, boxes, ellipses and text boxes (L, A, R, O, T). They follow the panel they are drawn on. |
|
|
116
|
+
| **Insets** | Connect a zoomed inset to the region it shows: a box and two lines that follow both plots. |
|
|
117
|
+
|
|
118
|
+
### How the plots look
|
|
119
|
+
|
|
120
|
+
| | |
|
|
121
|
+
|---|---|
|
|
122
|
+
| **Figure look** | Line, spine and tick widths, tick length and direction, despine, bar edges, and show or hide titles, axis labels, tick labels, legends, grid lines and colorbars. Set it for the whole figure, then override it for one panel. |
|
|
123
|
+
| **Palettes** | matplotlib's and seaborn's palettes, grouped by kind, or colours you choose. A palette is stored as its colours, so the published figure needs neither seaborn nor panelist. Each series is recoloured everywhere it appears: lines, error bands, bars, points and legend keys. |
|
|
124
|
+
| **Lines one by one** | Give any line its own colour, dash, width and marker; its legend key follows. |
|
|
125
|
+
| **Ticks and limits** | Log or symmetric log axes, where ticks go, how numbers are written, labels on each side, minor ticks. Type a plot's axis limits. |
|
|
126
|
+
| **Legends** | Set a legend's columns, frame, title and corner; drag it anywhere. |
|
|
127
|
+
|
|
128
|
+
### Output
|
|
129
|
+
|
|
130
|
+
| | |
|
|
131
|
+
|---|---|
|
|
132
|
+
| **Export** | Ctrl+E saves the figure as PDF, PNG, SVG or TIFF at the dpi you choose, from a fresh run of your script. Fonts stay text, as journals ask. |
|
|
133
|
+
| **Strict, repeatable output** | `apply_layout` checks every binding before it changes anything: a renamed or missing panel raises an error and the figure is left untouched. The same layout always compiles to the same file. |
|
|
134
|
+
| **Several layouts** | Keep several layouts of one figure, each its own file, and flip between the last two with Ctrl+Shift+L. |
|
|
135
|
+
|
|
136
|
+
### The editor
|
|
137
|
+
|
|
138
|
+
| | |
|
|
139
|
+
|---|---|
|
|
140
|
+
| **Two hosts** | The same canvas runs in a standalone window (`panelist edit`) and as a VS Code editor for `*.layout.json`. |
|
|
141
|
+
| **Commands** | Ctrl+K opens a palette with every command and every panel by name, `?` lists every shortcut, and right-click opens the arrange menu. |
|
|
142
|
+
| **Fast feedback** | While you move one panel, only that panel is redrawn. Every edit can be undone. The inspector shows exact millimetre values. |
|
|
143
|
+
|
|
144
|
+
## Screenshots
|
|
145
|
+
|
|
146
|
+
<table>
|
|
147
|
+
<tr>
|
|
148
|
+
<td width="50%">
|
|
149
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/editor.png" alt="The panelist editor on a four-panel figure"><br>
|
|
150
|
+
<sub><b>The editor:</b> layers on the left, the figure on its millimetre page, the inspector on the right.</sub>
|
|
151
|
+
</td>
|
|
152
|
+
<td width="50%">
|
|
153
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/text_styles.png" alt="The Text styles panel with the Nature preset"><br>
|
|
154
|
+
<sub><b>Text styles</b> (Alt+3): a journal preset, then any size, weight or font by kind of text.</sub>
|
|
155
|
+
</td>
|
|
156
|
+
</tr>
|
|
157
|
+
<tr>
|
|
158
|
+
<td width="50%">
|
|
159
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/journal_width.png" alt="Changing the page to Nature's single column: the change explained and previewed"><br>
|
|
160
|
+
<sub><b>A journal's column width</b> in one click: what will change is explained and previewed before anything moves.</sub>
|
|
161
|
+
</td>
|
|
162
|
+
<td width="50%">
|
|
163
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/crop.png" alt="A plot cropped like a photo, with its crop marks"><br>
|
|
164
|
+
<sub><b>Crop</b> (C): drag a plot's edge in; the plot gets smaller at the same data scale.</sub>
|
|
165
|
+
</td>
|
|
166
|
+
</tr>
|
|
167
|
+
<tr>
|
|
168
|
+
<td width="50%">
|
|
169
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/look_picker.png" alt="The palette picker: matplotlib and seaborn palettes grouped by kind"><br>
|
|
170
|
+
<sub><b>Palettes</b> from matplotlib and seaborn, grouped by kind, reversed if you like, or your own colours.</sub>
|
|
171
|
+
</td>
|
|
172
|
+
<td width="50%">
|
|
173
|
+
<img src="https://raw.githubusercontent.com/costantinoai/panelist/main/assets/palette.png" alt="The command palette"><br>
|
|
174
|
+
<sub><b>Ctrl+K</b> opens the command palette, with every command and every panel by name.</sub>
|
|
175
|
+
</td>
|
|
176
|
+
</tr>
|
|
177
|
+
</table>
|
|
178
|
+
|
|
179
|
+
## Install
|
|
180
|
+
|
|
181
|
+
panelist needs Python 3.10 or later and matplotlib 3.10 or 3.11.
|
|
182
|
+
|
|
183
|
+
**In VS Code:** install the extension **panelist** (`costantinoai.panelist-editor`) from the Extensions view. You can also download `panelist-editor-<version>.vsix` from the [latest release](https://github.com/costantinoai/panelist/releases/latest) and install it with `code --install-extension panelist-editor-<version>.vsix`. The extension carries panelist itself, so there is nothing to install with pip. It draws your figure with the Python selected in VS Code (`Python: Select Interpreter`), which needs matplotlib and your own plotting code.
|
|
184
|
+
|
|
185
|
+
**From a terminal:** the `panelist` command and the standalone editor window come from PyPI.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install panelist # the library and the panelist command
|
|
189
|
+
pip install "panelist[editor]" # the same, plus the editor window (PySide6 with QtWebEngine)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Install it into the Python environment that runs your plotting code.
|
|
193
|
+
|
|
194
|
+
To work on panelist itself, install it from a clone of this repository:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pip install -e ".[editor]"
|
|
198
|
+
cd editor && npm ci && npm run build && cd .. # build the canvas once (needs Node.js)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`environment.yml` is the tested conda environment with everything: `mamba env create -f environment.yml`.
|
|
202
|
+
|
|
203
|
+
## Usage
|
|
204
|
+
|
|
205
|
+
### 1. Point panelist at your figure
|
|
206
|
+
|
|
207
|
+
Write an *adapter*: a small `.py` file with a `build()` function that draws the figure with your own code and returns it together with the objects the layout may move.
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
import matplotlib.pyplot as plt
|
|
211
|
+
|
|
212
|
+
def build():
|
|
213
|
+
fig, (ax_a, ax_b) = plt.subplots(1, 2)
|
|
214
|
+
... # your plotting code
|
|
215
|
+
return fig, {"a": ax_a, "b": ax_b}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`panelist inspect adapter.py` lists everything in a figure that a layout can bind (Axes, figure texts, legends).
|
|
219
|
+
|
|
220
|
+
When your plotting code saves its figure itself, two helpers keep every adapter a few lines long (adapters run only in the editor, so they may import panelist; the published figure never does):
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from panelist.adapters import capture, letter_by_size, targets_by_letter
|
|
224
|
+
from mypaper import figures, panels
|
|
225
|
+
|
|
226
|
+
def build():
|
|
227
|
+
fig = capture(lambda: figures.fig3(), intercept=[(panels, "save")]) # runs your code, writes nothing
|
|
228
|
+
return fig, targets_by_letter(fig, letter=letter_by_size(8)) # "a.ax00", "a.t_title", "head", "legend0"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
`capture` holds every `savefig` (and any save function you name) and returns the figure; `targets_by_letter` names each plot, text and legend by the panel letter above-left of it, in drawing order, so the names stay put while your code does.
|
|
232
|
+
|
|
233
|
+
### 2. Edit, check, compile
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
panelist edit fig.layout.json # open the layout on the canvas
|
|
237
|
+
panelist validate fig.layout.json # report every problem by JSON path
|
|
238
|
+
panelist apply fig.layout.json adapter.py -o fig.png [--dpi 300] # save through the generated code, fonts embedded
|
|
239
|
+
panelist compile panelist-layouts/ # every figure of a project: small modules sharing one panelist_runtime.py
|
|
240
|
+
panelist compile fig.layout.json # write fig_layout.py next to the layout (fig.compact.layout.json: fig_compact_layout.py)
|
|
241
|
+
panelist styles # list the style presets, built-in and your own
|
|
242
|
+
panelist styles new|check # start a preset file, check one (see below)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
In VS Code these steps need no terminal. Right-click the figure script and choose "panelist: New layout for this figure script"; the layout opens on the canvas. "Save and compile" in the editor's Export section writes `fig_layout.py` beside the script.
|
|
246
|
+
|
|
247
|
+
### 3. Apply the layout in your script
|
|
248
|
+
|
|
249
|
+
Import the compiled module and call `apply_layout` once, as shown in [How it works](#how-it-works).
|
|
250
|
+
|
|
251
|
+
### Your own style presets (a journal, a lab, a poster)
|
|
252
|
+
|
|
253
|
+
A preset is one JSON file: text styles by kind of text, the figure's look (line, spine and tick widths), journal page widths, or any mix. Its file name is its id. Your presets live in `~/.config/panelist/styles/` (or in the folders named by `PANELIST_STYLES`) and appear in the Text styles menu and the command palette the next time a layout is opened.
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
panelist styles new lab-poster # a starter file in your styles folder (never overwrites)
|
|
257
|
+
panelist styles new my-journal --from nature # a copy of a preset to change; its source and dates are emptied
|
|
258
|
+
panelist styles check ~/.config/panelist/styles/lab-poster.json # every mistake by its place in the file, and fonts not installed here
|
|
259
|
+
panelist styles # every preset panelist sees, and any broken file
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The starter names the schema (`"$schema"`), so VS Code and other JSON editors complete the keys and flag mistakes while you type. A full example:
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"name": "My journal",
|
|
267
|
+
"description": "Arial 6-8 pt, thin lines",
|
|
268
|
+
"source": "https://example.org/author-guide/figures",
|
|
269
|
+
"checked": "2026-11-26",
|
|
270
|
+
"roles": {
|
|
271
|
+
"panel_letter": {"size": 8, "weight": "bold"},
|
|
272
|
+
"title": {"size": 8, "weight": "bold", "family": ["Arial", "DejaVu Sans"]},
|
|
273
|
+
"axis_label": {"size": 7, "family": ["Arial", "DejaVu Sans"]},
|
|
274
|
+
"tick_label": {"size": 6, "family": ["Arial", "DejaVu Sans"]},
|
|
275
|
+
"legend": {"size": 6, "family": ["Arial", "DejaVu Sans"]}
|
|
276
|
+
},
|
|
277
|
+
"look": {"line_width_pt": 0.75, "spine_width_pt": 0.5, "tick_width_pt": 0.5, "tick_length_pt": 2.5, "tick_direction": "out"},
|
|
278
|
+
"page": {
|
|
279
|
+
"widths_mm": {"Single column": 85, "Double column": 175},
|
|
280
|
+
"max_height_mm": 230,
|
|
281
|
+
"source": "https://example.org/author-guide/artwork",
|
|
282
|
+
"checked": "2026-11-26"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| key | what it holds |
|
|
288
|
+
|---|---|
|
|
289
|
+
| `name` | the name in the menu (required) |
|
|
290
|
+
| `roles` | a style per kind of text: `panel_letter`, `title`, `axis_label`, `tick_label`, `legend`, `legend_title`, `annotation`. A style takes `size` (pt), `weight` (`normal`, `bold`), `style` (`normal`, `italic`) and `family` (fonts in order of preference; end with `DejaVu Sans`, which matplotlib ships) |
|
|
291
|
+
| `look` | the figure's look, as in the Look section: `line_width_pt`, `spine_width_pt`, `tick_width_pt`, `tick_length_pt`, `bar_edge_width_pt`, `tick_direction` (`in`, `out`, `inout`), `spines`, `show`, `bar_edge_color`, `palette` |
|
|
292
|
+
| `page` | journal widths: `widths_mm` (label → mm), `max_height_mm`, and the guide they come from |
|
|
293
|
+
| `rules` | what Check tests: `min_text_pt`, `max_text_pt`, `letter_max_pt` (panel letters' own cap), with the guide's `source` and `checked` |
|
|
294
|
+
| `description`, `source`, `checked`, `comment` | free text; for a journal, `source` is the guide's URL and `checked` the date it was read |
|
|
295
|
+
|
|
296
|
+
Picking a preset makes the layout follow it by reference (`"preset": "lab"`): its text styles and look are filled in when the layout is compiled, so edit the preset once and every figure that names it follows; anything you set in the layout itself still wins. For a shared project, keep presets beside the layouts in `panelist-layouts/presets/` (`panelist styles new lab --dir panelist-layouts/presets`), so they are versioned with your figures. Journal widths appear in the Page section. Take a journal's numbers from its own author guide and note where (`source`, `checked`); `panelist styles check` reminds you when they are empty. A file with a mistake is skipped, and `panelist styles` says which one and why.
|
|
297
|
+
|
|
298
|
+
### Try the demo
|
|
299
|
+
|
|
300
|
+
`examples/demo/` has a four-panel figure with made-up data, the one in the screenshots:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
cd examples/demo
|
|
304
|
+
panelist edit demo_figure.py # opens panelist-layouts/demo.layout.json (it draws this script)
|
|
305
|
+
panelist compile panelist-layouts/demo.layout.json # writes demo_layout.py beside demo_figure.py
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
<details>
|
|
309
|
+
<summary><b>Editor shortcuts</b></summary>
|
|
310
|
+
|
|
311
|
+
| Action | How |
|
|
312
|
+
|---|---|
|
|
313
|
+
| Move | drag; Shift-drag for straight moves |
|
|
314
|
+
| Nudge | arrow keys (0.1 mm), Shift + arrow (1 mm) |
|
|
315
|
+
| Ignore snapping | hold Alt |
|
|
316
|
+
| Resize an Axes | drag a handle |
|
|
317
|
+
| Select several | Shift-click, or drag a box |
|
|
318
|
+
| Enter / leave a group | double-click / Esc |
|
|
319
|
+
| Arrange tools | right-click |
|
|
320
|
+
| Draw a line, arrow, box, ellipse, text box | L, A, R, O, T, then drag (Shift: 45° steps, squares) |
|
|
321
|
+
| Delete a shape or text | Delete |
|
|
322
|
+
| Crop a plot | C, then drag its edges or corners (Esc: done) |
|
|
323
|
+
| Text styles | Alt+3, or the T button |
|
|
324
|
+
| Command palette | Ctrl+K |
|
|
325
|
+
| All shortcuts | `?` |
|
|
326
|
+
|
|
327
|
+
</details>
|
|
328
|
+
|
|
329
|
+
<details>
|
|
330
|
+
<summary><b>VS Code</b></summary>
|
|
331
|
+
|
|
332
|
+
Install the `.vsix` from the [latest release](https://github.com/costantinoai/panelist/releases/latest) with `code --install-extension panelist-editor-<version>.vsix`. From a clone you can build the same file (`cd editor && npm ci && npm run package`) or open `editor/` as an extension without installing (`npm run build`, then `code --extensionDevelopmentPath=<repo>/editor <folder>`). Files named `*.layout.json` then open on the canvas. Set `panelist.python` to a Python that can import your plotting code, and `panelist.pythonPath` to any extra `PYTHONPATH` it needs.
|
|
333
|
+
|
|
334
|
+
</details>
|
|
335
|
+
|
|
336
|
+
The layout format, every command and how to extend panelist are documented in [AGENTS.md](https://github.com/costantinoai/panelist/blob/main/AGENTS.md). Working with an AI agent? Point it at that file: it says how to install panelist, where a figure's files are saved, and how to lay out a figure step by step from a terminal.
|
|
337
|
+
|
|
338
|
+
## Related projects
|
|
339
|
+
|
|
340
|
+
| | Where the layout lives | How you edit it | What your script does |
|
|
341
|
+
|---|---|---|---|
|
|
342
|
+
| [pylustrator](https://github.com/rgerum/pylustrator) | generated code written into your script | drag in an interactive window | runs the generated code |
|
|
343
|
+
| [FigureFirst](https://github.com/FlyRanch/figurefirst) | an SVG file | draw and tag rectangles in Inkscape | reads the SVG through FigureFirst |
|
|
344
|
+
| matplotlib layout tools | your code | numbers and ratios in code | contains the layout |
|
|
345
|
+
| Vector editors | the exported file | by hand, after every export | nothing; edits are lost on regeneration |
|
|
346
|
+
| **panelist** | `fig.layout.json` next to your code | drag on the rendered figure | one `apply_layout` call, matplotlib only |
|
|
347
|
+
|
|
348
|
+
**[pylustrator](https://github.com/rgerum/pylustrator)** (Gerum, [JOSS 2019](https://doi.org/10.21105/joss.01989)) opens a matplotlib figure in an interactive window and saves your changes as generated Python code inside your plotting script. panelist grew out of working with pylustrator and keeps its central idea: edit with the mouse, reproduce the result with code. But panelist writes the result to a separate layout file and never touches your script; it binds panels by name, refuses a layout that does not match, and works in page millimetres with grids and groups. panelist is written from scratch and shares no code with pylustrator.
|
|
349
|
+
|
|
350
|
+
**[FigureFirst](https://github.com/FlyRanch/figurefirst)** (Lindsay, van Breugel and Weir, SciPy 2017) also starts from the layout: you draw rectangles in Inkscape, tag them, and FigureFirst turns the SVG into matplotlib Axes. panelist keeps the layout apart from the plotting code in the same way, but you edit it on the rendered figure itself, and the published figure needs only matplotlib.
|
|
351
|
+
|
|
352
|
+
**matplotlib's own tools** (`subplot_mosaic`, gridspec, constrained layout) describe the arrangement in code and suit regular grids. panelist does not replace them. It is for the last step, where panels need exact sizes and positions on a fixed page and are easier to place by eye than by trial and error.
|
|
353
|
+
|
|
354
|
+
## Status
|
|
355
|
+
|
|
356
|
+
> [!NOTE]
|
|
357
|
+
> panelist is an early version (0.1). The layout format is versioned (`"panelist": 1`) and may still change before 1.0.
|
|
358
|
+
|
|
359
|
+
## Citing and license
|
|
360
|
+
|
|
361
|
+
If you use panelist in a publication, GitHub's *Cite this repository* button gives the reference from [`CITATION.cff`](https://github.com/costantinoai/panelist/blob/main/CITATION.cff). panelist is released under the [MIT License](https://github.com/costantinoai/panelist/blob/main/LICENSE).
|