pltbrowser 0.1.0__py3-none-any.whl

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.
pltbrowser/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Browse nested mappings of Matplotlib figures in one window."""
2
+
3
+ from .browser import FigureBrowser
4
+ from .figures import save_figures, walk_figures
5
+
6
+ __all__ = ["FigureBrowser", "save_figures", "walk_figures"]
pltbrowser/browser.py ADDED
@@ -0,0 +1,336 @@
1
+ """Single-window browser for nested mappings of Matplotlib figures."""
2
+
3
+ import threading
4
+
5
+ import matplotlib
6
+ import matplotlib.pyplot as plt
7
+ from matplotlib.backend_bases import FigureCanvasBase
8
+ from matplotlib.backends.backend_qtagg import (
9
+ FigureCanvasQTAgg, NavigationToolbar2QT,
10
+ )
11
+ from matplotlib.backends.qt_compat import QtCore, QtGui, QtWidgets
12
+ from matplotlib.colors import to_hex, to_rgb
13
+ from matplotlib.figure import Figure
14
+
15
+ from .figures import walk_figures
16
+ from .flow import FlowLayout, find_tiles
17
+
18
+
19
+ # colors of the light window theme, besides the accent
20
+ TEXT = "#374151"
21
+ BACKGROUND = "#F7F8FA"
22
+
23
+ # height of a row of the figure tree, in pixels
24
+ ROW_HEIGHT = 28
25
+
26
+ # tree-item data role that holds the index of the item's figure
27
+ _FIGURE = QtCore.Qt.ItemDataRole.UserRole.value
28
+
29
+
30
+ class FigureBrowser:
31
+ """Browse a nested mapping of Matplotlib figures in one Qt window.
32
+
33
+ A tree on the left mirrors the nesting of the mapping; the selected
34
+ figure is displayed on the right. The figures leave their pyplot
35
+ windows when the browser is created, and get their size, resolution,
36
+ and subplot grid back when the browser is closed.
37
+
38
+ Parameters
39
+ ----------
40
+ figures : mapping
41
+ Maps names to Matplotlib figures or to nested mappings of them.
42
+ title : str, optional
43
+ Title of the window and heading of the figure tree.
44
+ accent : color, optional
45
+ Any Matplotlib color, used for the heading and the selection.
46
+ label : callable, optional
47
+ Returns the text displayed in the tree for a name of the mapping.
48
+ size : tuple of int, optional
49
+ Initial width and height of the window, in pixels.
50
+ interactive : bool, optional
51
+ Whether figures have the Matplotlib toolbar and respond to the
52
+ mouse and the keyboard.
53
+ flow_layout : bool, optional
54
+ Whether subplot grids are rearranged to fit the window, like
55
+ MATLAB's ``tiledlayout('flow')``. Grids with shared axes,
56
+ spanning subplots, or freely placed axes are left as they are.
57
+
58
+ Attributes
59
+ ----------
60
+ window : QMainWindow
61
+ Qt window of the browser.
62
+ selected : matplotlib.figure.Figure
63
+ Figure on display.
64
+ """
65
+
66
+ def __init__(
67
+ self, figures, title="Figures", accent="tab:blue", label=str,
68
+ size=(1380, 840), interactive=True, flow_layout=False,
69
+ ):
70
+ leaves = list(walk_figures(figures))
71
+ if not leaves:
72
+ raise ValueError("The figure browser needs at least one figure.")
73
+ if threading.current_thread() is not threading.main_thread():
74
+ raise RuntimeError(
75
+ "The figure browser must be created on the main thread, "
76
+ "where Qt windows live."
77
+ )
78
+ self.figures = figures
79
+ self.interactive = bool(interactive)
80
+ self.flow_layout = bool(flow_layout)
81
+ self.selected = None
82
+ self._label = label
83
+ self._figures = []
84
+ self._first = None
85
+ self._pages = {}
86
+
87
+ # the pyplot windows of the figures would open next to the browser
88
+ for _, figure in leaves:
89
+ plt.close(figure)
90
+
91
+ # an empty canvas lets Matplotlib create and set up the Qt
92
+ # application, which must exist before any widget
93
+ FigureCanvasQTAgg(Figure())
94
+
95
+ self._build_window(title, accent, size)
96
+ self._add_items(figures, self._tree)
97
+ for index in range(self._tree.topLevelItemCount()):
98
+ self._tree.topLevelItem(index).setExpanded(True)
99
+ self._tree.setCurrentItem(self._first)
100
+
101
+ def show(self, block=None):
102
+ """Display the browser.
103
+
104
+ Parameters
105
+ ----------
106
+ block : bool, optional
107
+ Whether to wait until the window is closed. By default, as
108
+ in Matplotlib: wait unless interactive mode is on.
109
+ """
110
+
111
+ # closing the window released the figures: display one again
112
+ self._display(self.selected)
113
+ self.window.show()
114
+ self.window.raise_()
115
+ self.window.activateWindow()
116
+
117
+ if block is None:
118
+ block = not matplotlib.is_interactive()
119
+ if block:
120
+ # a local event loop returns when this window closes, even
121
+ # if other Qt windows stay open
122
+ loop = QtCore.QEventLoop()
123
+ self.window.closed.connect(loop.quit)
124
+ loop.exec()
125
+
126
+ def close(self):
127
+ """Close the browser window."""
128
+
129
+ self.window.close()
130
+
131
+ def _build_window(self, title, accent, size):
132
+ """Create the window: the figure tree on the left, the path and
133
+ the canvas of the selected figure on the right."""
134
+
135
+ self.window = _Window()
136
+ self.window.setWindowTitle(title)
137
+ self.window.resize(*size)
138
+ self.window.closed.connect(self._release)
139
+
140
+ # every widget inherits the light palette, whatever the system
141
+ # theme; a style sheet here would stop that inheritance
142
+ central = QtWidgets.QWidget()
143
+ central.setPalette(_palette(accent))
144
+ central.setAutoFillBackground(True)
145
+ self.window.setCentralWidget(central)
146
+
147
+ # left: heading and figure tree; a label with a style sheet does
148
+ # not inherit the palette, so its color is always given
149
+ heading = QtWidgets.QLabel(title)
150
+ heading.setStyleSheet(
151
+ f"color: {to_hex(accent)}; font-size: 14pt; font-weight: bold;"
152
+ )
153
+ self._tree = QtWidgets.QTreeWidget()
154
+ self._tree.setHeaderHidden(True)
155
+ self._tree.setAnimated(True)
156
+ self._tree.currentItemChanged.connect(self._select)
157
+ navigation = QtWidgets.QWidget()
158
+ navigation.setMinimumWidth(200)
159
+ column = QtWidgets.QVBoxLayout(navigation)
160
+ column.addWidget(heading)
161
+ column.addWidget(self._tree, 1)
162
+
163
+ # right: path of the selected figure and one page per figure
164
+ self._breadcrumb = QtWidgets.QLabel()
165
+ self._breadcrumb.setStyleSheet(
166
+ f"color: {TEXT}; font-size: 10pt; font-weight: bold;"
167
+ )
168
+ self._breadcrumb.setWordWrap(True)
169
+ self._stack = QtWidgets.QStackedWidget()
170
+ content = QtWidgets.QWidget()
171
+ column = QtWidgets.QVBoxLayout(content)
172
+ column.addWidget(self._breadcrumb)
173
+ column.addWidget(self._stack, 1)
174
+
175
+ splitter = QtWidgets.QSplitter()
176
+ splitter.addWidget(navigation)
177
+ splitter.addWidget(content)
178
+ splitter.setStretchFactor(1, 1)
179
+ splitter.setSizes([285, size[0] - 285])
180
+ QtWidgets.QHBoxLayout(central).addWidget(splitter)
181
+
182
+ def _add_items(self, figures, parent):
183
+ """Mirror one level of the figure mapping below ``parent``."""
184
+
185
+ for name, value in figures.items():
186
+ text = str(self._label(name))
187
+ item = QtWidgets.QTreeWidgetItem(parent, [text])
188
+ item.setToolTip(0, _path(item))
189
+ item.setSizeHint(0, QtCore.QSize(0, ROW_HEIGHT))
190
+ if isinstance(value, Figure):
191
+ item.setData(0, _FIGURE, len(self._figures))
192
+ self._figures.append(value)
193
+ if self._first is None:
194
+ self._first = item
195
+ else:
196
+ font = item.font(0)
197
+ font.setBold(True)
198
+ item.setFont(0, font)
199
+ self._add_items(value, item)
200
+
201
+ def _select(self, item, previous=None):
202
+ """Display the figure of a tree item; a group only unfolds."""
203
+
204
+ if item is None:
205
+ return
206
+ index = item.data(0, _FIGURE)
207
+ if index is None:
208
+ item.setExpanded(True)
209
+ return
210
+ self._breadcrumb.setText(_path(item))
211
+ self._display(self._figures[index])
212
+
213
+ def _display(self, figure):
214
+ """Bring the page of a figure to the front, creating it on the
215
+ first visit so that hidden figures cost nothing."""
216
+
217
+ page = self._pages.get(figure)
218
+ if page is None:
219
+ page = _Page(figure, self.interactive, self.flow_layout)
220
+ self._pages[figure] = page
221
+ self._stack.addWidget(page)
222
+ self._stack.setCurrentWidget(page)
223
+ self.selected = figure
224
+
225
+ # show what changed while the figure was hidden
226
+ page.canvas.draw_idle()
227
+ if self.interactive:
228
+ page.canvas.setFocus()
229
+
230
+ def _release(self):
231
+ """Give every displayed figure back as it was."""
232
+
233
+ for page in self._pages.values():
234
+ page.release()
235
+ self._stack.removeWidget(page)
236
+ page.deleteLater()
237
+ self._pages.clear()
238
+
239
+
240
+ class _Window(QtWidgets.QMainWindow):
241
+ """Main window that tells when it is closed."""
242
+
243
+ closed = QtCore.Signal()
244
+
245
+ def closeEvent(self, event):
246
+ super().closeEvent(event)
247
+ self.closed.emit()
248
+
249
+
250
+ class _Page(QtWidgets.QWidget):
251
+ """Canvas and toolbar of one figure on display."""
252
+
253
+ def __init__(self, figure, interactive, flow_layout):
254
+ super().__init__()
255
+ self.figure = figure
256
+ # what the Qt canvas changes in the figure, for release()
257
+ self._dpi = figure.dpi
258
+ self._size = figure.get_size_inches()
259
+ self._flow = None
260
+
261
+ self.canvas = FigureCanvasQTAgg(figure)
262
+ layout = QtWidgets.QVBoxLayout(self)
263
+ layout.setContentsMargins(0, 0, 0, 0)
264
+ layout.setSpacing(4)
265
+ if interactive:
266
+ layout.addWidget(NavigationToolbar2QT(self.canvas, self))
267
+ else:
268
+ # ignore the mouse and the keyboard without looking disabled
269
+ attributes = QtCore.Qt.WidgetAttribute
270
+ self.canvas.setAttribute(
271
+ attributes.WA_TransparentForMouseEvents
272
+ )
273
+ self.canvas.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
274
+
275
+ rows = _table_rows(figure)
276
+ if rows:
277
+ # a table keeps a readable row height and scrolls
278
+ self.canvas.setMinimumHeight(max(500, 28 * rows + 100))
279
+ area = QtWidgets.QScrollArea()
280
+ area.setWidgetResizable(True)
281
+ area.setWidget(self.canvas)
282
+ layout.addWidget(area, 1)
283
+ else:
284
+ layout.addWidget(self.canvas, 1)
285
+ tiles = find_tiles(figure) if flow_layout else None
286
+ if tiles:
287
+ self._flow = FlowLayout(figure, tiles)
288
+
289
+ def release(self):
290
+ """Give the figure back as it was before it was displayed."""
291
+
292
+ if self._flow is not None:
293
+ self._flow.restore()
294
+ self.figure.dpi = self._dpi
295
+ self.figure.set_size_inches(self._size, forward=False)
296
+ # a plain canvas detaches the figure from the Qt widget
297
+ FigureCanvasBase(self.figure)
298
+
299
+
300
+ def _path(item):
301
+ """Return the labels from the top of the tree down to ``item``."""
302
+
303
+ labels = []
304
+ while item is not None:
305
+ labels.insert(0, item.text(0))
306
+ item = item.parent()
307
+ return " / ".join(labels)
308
+
309
+
310
+ def _table_rows(figure):
311
+ """Return the row count of the longest table of a figure."""
312
+
313
+ return max(
314
+ (
315
+ 1 + max(row for row, _ in table.get_celld())
316
+ for axis in figure.axes for table in axis.tables
317
+ if table.get_celld()
318
+ ),
319
+ default=0,
320
+ )
321
+
322
+
323
+ def _palette(accent):
324
+ """Return the light palette of the browser for an accent color."""
325
+
326
+ roles = QtGui.QPalette.ColorRole
327
+ palette = QtGui.QPalette(QtGui.QColor(BACKGROUND))
328
+ for role in (
329
+ roles.WindowText, roles.Text, roles.ButtonText,
330
+ roles.HighlightedText,
331
+ ):
332
+ palette.setColor(role, QtGui.QColor(TEXT))
333
+ # the selection is a light tint of the accent, under dark text
334
+ tint = (1.0 - 0.18 * (1.0 - value) for value in to_rgb(accent))
335
+ palette.setColor(roles.Highlight, QtGui.QColor.fromRgbF(*tint))
336
+ return palette
pltbrowser/figures.py ADDED
@@ -0,0 +1,77 @@
1
+ """Nested mappings of Matplotlib figures: traversal and file export."""
2
+
3
+ import re
4
+ from collections.abc import Mapping
5
+ from pathlib import Path
6
+
7
+ from matplotlib.figure import Figure
8
+
9
+
10
+ def walk_figures(figures, path=()):
11
+ """Yield ``(path, figure)`` for every figure of a nested mapping.
12
+
13
+ Parameters
14
+ ----------
15
+ figures : mapping
16
+ Maps names to Matplotlib figures or to nested mappings of them.
17
+ path : tuple of str, optional
18
+ Names that lead to ``figures`` inside an enclosing mapping.
19
+
20
+ Yields
21
+ ------
22
+ path : tuple of str
23
+ Names that lead to the figure, outermost first.
24
+ figure : matplotlib.figure.Figure
25
+ Figure found at that path.
26
+ """
27
+
28
+ if not isinstance(figures, Mapping):
29
+ raise TypeError(
30
+ "Figures must be given as a mapping from names to figures or "
31
+ "to nested mappings of figures."
32
+ )
33
+ for name, value in figures.items():
34
+ branch = path + (str(name),)
35
+ if isinstance(value, Figure):
36
+ yield branch, value
37
+ elif isinstance(value, Mapping):
38
+ yield from walk_figures(value, branch)
39
+ else:
40
+ raise TypeError(
41
+ f"{' / '.join(branch)} is a {type(value).__name__}, not "
42
+ "a Matplotlib figure or a mapping of figures."
43
+ )
44
+
45
+
46
+ def save_figures(figures, directory, formats=("png",), **options):
47
+ """Save every figure of a nested mapping, one folder per group.
48
+
49
+ The figure ``figures["a"]["b"]`` is written to ``directory/a/b.png``.
50
+
51
+ Parameters
52
+ ----------
53
+ figures : mapping
54
+ Maps names to Matplotlib figures or to nested mappings of them.
55
+ directory : path-like
56
+ Root output folder, created when missing.
57
+ formats : str or sequence of str, optional
58
+ File extensions that Matplotlib can write, such as ``"png"`` or
59
+ ``"pdf"``.
60
+ **options
61
+ Passed to :meth:`matplotlib.figure.Figure.savefig`.
62
+ """
63
+
64
+ if isinstance(formats, str):
65
+ formats = (formats,)
66
+ for path, figure in walk_figures(figures):
67
+ *folders, name = (_file_name(part) for part in path)
68
+ folder = Path(directory).joinpath(*folders)
69
+ folder.mkdir(parents=True, exist_ok=True)
70
+ for extension in formats:
71
+ figure.savefig(folder / f"{name}.{extension}", **options)
72
+
73
+
74
+ def _file_name(name):
75
+ """Replace the characters that file systems reject."""
76
+
77
+ return re.sub(r'[<>:"/\\|?*\x00-\x1f]', "_", name).strip(" .") or "_"
pltbrowser/flow.py ADDED
@@ -0,0 +1,132 @@
1
+ """Subplot grids that follow the shape of their canvas."""
2
+
3
+ import math
4
+
5
+ from matplotlib.gridspec import GridSpec
6
+
7
+
8
+ # margins and spacings that a rearranged grid inherits from the original
9
+ _MARGINS = ("left", "bottom", "right", "top", "wspace", "hspace")
10
+
11
+
12
+ def find_tiles(figure):
13
+ """Return the subplots of a figure that a flow layout can rearrange.
14
+
15
+ A grid can be rearranged when its subplots fill one uniform
16
+ ``GridSpec`` row by row, each on one cell, and share no axis with
17
+ another subplot.
18
+
19
+ Returns
20
+ -------
21
+ list of list of Axes or None
22
+ Axes of every subplot in reading order (twin axes belong to the
23
+ same subplot), or ``None`` when the grid must stay as it is.
24
+ """
25
+
26
+ tiles = {}
27
+ grids = set()
28
+ for axis in figure.axes:
29
+ spec = axis.get_subplotspec()
30
+ # freely placed axes, subfigures, and subplots that span cells
31
+ if (
32
+ spec is None or axis.figure is not figure
33
+ or spec.num1 != spec.num2
34
+ ):
35
+ return None
36
+ grids.add(spec.get_gridspec())
37
+ tiles.setdefault(spec.num1, []).append(axis)
38
+ if len(tiles) < 2 or len(grids) != 1:
39
+ return None
40
+
41
+ # one plain grid of equal cells, filled row by row without gaps
42
+ grid = grids.pop()
43
+ if (
44
+ not isinstance(grid, GridSpec)
45
+ or len(set(grid.get_width_ratios() or [1])) != 1
46
+ or len(set(grid.get_height_ratios() or [1])) != 1
47
+ or sorted(tiles) != list(range(len(tiles)))
48
+ or grid.nrows != math.ceil(len(tiles) / grid.ncols)
49
+ ):
50
+ return None
51
+
52
+ # moving subplots that share an axis would misplace their tick labels
53
+ tile_of = {axis: cell for cell in tiles for axis in tiles[cell]}
54
+ for axis, cell in tile_of.items():
55
+ shared = (
56
+ *axis.get_shared_x_axes().get_siblings(axis),
57
+ *axis.get_shared_y_axes().get_siblings(axis),
58
+ )
59
+ if any(tile_of.get(other, cell) != cell for other in shared):
60
+ return None
61
+ return [tiles[cell] for cell in sorted(tiles)]
62
+
63
+
64
+ class FlowLayout:
65
+ """Rearrange the subplot grid of a figure when its canvas is resized.
66
+
67
+ The subplots keep their order and move to the grid whose cells are
68
+ closest in shape to the cells the figure was created with, like
69
+ MATLAB's ``tiledlayout('flow')``. Only the grid changes: limits,
70
+ aspect ratios, and artists are untouched.
71
+
72
+ Parameters
73
+ ----------
74
+ figure : matplotlib.figure.Figure
75
+ Figure whose subplots are rearranged.
76
+ tiles : list of list of Axes
77
+ Subplots of the figure, as returned by :func:`find_tiles`.
78
+ """
79
+
80
+ def __init__(self, figure, tiles):
81
+ grid = tiles[0][0].get_gridspec()
82
+ width, height = figure.get_size_inches()
83
+ self.figure = figure
84
+ self.tiles = tiles
85
+ self.shape = (grid.nrows, grid.ncols)
86
+ # width over height of one cell of the original grid
87
+ self.cell_aspect = (width / grid.ncols) / (height / grid.nrows)
88
+ self._margins = {name: getattr(grid, name) for name in _MARGINS}
89
+ self._specs = [tile[0].get_subplotspec() for tile in tiles]
90
+ self._connection = figure.canvas.mpl_connect(
91
+ "resize_event", self.reflow
92
+ )
93
+
94
+ def reflow(self, event=None):
95
+ """Move the subplots to the best grid for the figure size."""
96
+
97
+ shape = self._best_shape()
98
+ if shape == self.shape:
99
+ return
100
+ grid = GridSpec(*shape, figure=self.figure, **self._margins)
101
+ self._place([grid[index] for index in range(len(self.tiles))])
102
+ self.shape = shape
103
+
104
+ def restore(self):
105
+ """Stop following the canvas and return to the original grid."""
106
+
107
+ self.figure.canvas.mpl_disconnect(self._connection)
108
+ self._place(self._specs)
109
+ self.shape = self._specs[0].get_gridspec().get_geometry()
110
+
111
+ def _best_shape(self):
112
+ """Return the ``(rows, columns)`` that cover most of the figure
113
+ with cells of the original aspect."""
114
+
115
+ width, height = self.figure.get_size_inches()
116
+ if width <= 0.0 or height <= 0.0:
117
+ return self.shape
118
+ count = len(self.tiles)
119
+
120
+ def covered(columns):
121
+ rows = math.ceil(count / columns)
122
+ aspect = (width / columns) / (height / rows)
123
+ fit = min(aspect / self.cell_aspect, self.cell_aspect / aspect)
124
+ return fit * count / (rows * columns)
125
+
126
+ columns = max(range(1, count + 1), key=covered)
127
+ return math.ceil(count / columns), columns
128
+
129
+ def _place(self, specs):
130
+ for tile, spec in zip(self.tiles, specs):
131
+ for axis in tile:
132
+ axis.set_subplotspec(spec)
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: pltbrowser
3
+ Version: 0.1.0
4
+ Summary: Browse many Matplotlib figures in one window, organized as a tree
5
+ License-Expression: MIT
6
+ Keywords: matplotlib,figures,plots,browser,qt
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Framework :: Matplotlib
10
+ Classifier: Topic :: Scientific/Engineering :: Visualization
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: matplotlib>=3.8
15
+ Requires-Dist: PySide6>=6.5
16
+ Dynamic: license-file
17
+
18
+ # pltbrowser
19
+
20
+ One window for all your Matplotlib figures.
21
+
22
+ A script that produces dozens of figures usually opens dozens of windows.
23
+ `pltbrowser` shows them in a single window instead: you organize the
24
+ figures in a nested dictionary, and a tree on the left lets you move
25
+ between them. Each figure keeps the usual Matplotlib toolbar (zoom, pan,
26
+ save).
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install pltbrowser
32
+ ```
33
+
34
+ This installs Matplotlib and PySide6 (Qt 6) if they are missing.
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ import matplotlib.pyplot as plt
40
+ import numpy as np
41
+ from pltbrowser import FigureBrowser
42
+
43
+ t = np.linspace(0.0, 10.0, 200)
44
+
45
+
46
+ def plot(values, title):
47
+ figure, axis = plt.subplots()
48
+ axis.plot(t, values)
49
+ axis.set_title(title)
50
+ return figure
51
+
52
+
53
+ figures = {
54
+ "signals": {
55
+ "sine": plot(np.sin(t), "Sine"),
56
+ "cosine": plot(np.cos(t), "Cosine"),
57
+ },
58
+ "envelope": plot(np.exp(-0.3 * t), "Envelope"),
59
+ }
60
+
61
+ FigureBrowser(figures).show()
62
+ ```
63
+
64
+ The dictionary can be nested as deeply as you like: every level becomes a
65
+ group in the tree, and every figure a leaf. `show()` waits until the
66
+ window is closed, like `plt.show()`.
67
+
68
+ ## Options
69
+
70
+ ```python
71
+ FigureBrowser(
72
+ figures,
73
+ title="My results", # window title and tree heading
74
+ accent="tab:orange", # any Matplotlib color
75
+ label=str.title, # text shown in the tree for each key
76
+ size=(1380, 840), # initial window size in pixels
77
+ interactive=True, # toolbar, mouse, and keyboard
78
+ flow_layout=False, # rearrange subplots to fit the window
79
+ )
80
+ ```
81
+
82
+ With `flow_layout=True`, the subplots of a figure move to the grid that
83
+ best fits the window, like MATLAB's `tiledlayout('flow')`. Figures with
84
+ shared axes, spanning subplots, or freely placed axes keep their layout.
85
+
86
+ ## Saving
87
+
88
+ `save_figures` writes the same dictionary to disk, one folder per group:
89
+
90
+ ```python
91
+ from pltbrowser import save_figures
92
+
93
+ save_figures(figures, "plots", formats=("png", "pdf"), dpi=300)
94
+ ```
95
+
96
+ This creates `plots/signals/sine.png`, `plots/signals/sine.pdf`, and so
97
+ on. Extra keyword arguments go to Matplotlib's `savefig`.
98
+
99
+ ## Good to know
100
+
101
+ - The browser needs a desktop: it does not display inside Jupyter
102
+ notebooks.
103
+ - Figures are resized to fit the window while they are displayed. They
104
+ get their original size back when the window is closed, so saving
105
+ them afterwards gives the same files as before.
106
+
107
+ ## License
108
+
109
+ `pltbrowser` is released under the [MIT License](LICENSE).
@@ -0,0 +1,9 @@
1
+ pltbrowser/__init__.py,sha256=t_Kjj80_1RJNgI7KWlai9XFVHI42Uk50MnPHF3pEpB8,211
2
+ pltbrowser/browser.py,sha256=qcACFRhFwWcZxxNlbpzlPINvK40G8PgtjhUdBsyEhrw,11732
3
+ pltbrowser/figures.py,sha256=ZJ2bcCk1Q_1WTuwX1rv9VNF7RQhYu2yGy0VjTigAas4,2499
4
+ pltbrowser/flow.py,sha256=0b-Qoy_YvB1lXRcZ57Js1R_xvJgwDepztZpvyhLWZT4,4675
5
+ pltbrowser-0.1.0.dist-info/licenses/LICENSE,sha256=qNhHlsxIFQDwa24pElFuka_MxJtu1Xl9KtzTqOwqx8Q,1065
6
+ pltbrowser-0.1.0.dist-info/METADATA,sha256=23st_3LXCQCraqNcICWMAL1crCsaKs93J9Sg0khFaws,3035
7
+ pltbrowser-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ pltbrowser-0.1.0.dist-info/top_level.txt,sha256=PcTp7pJexRvZbndATxrRuNrm0y82X5jMpVvBPNZy2uM,11
9
+ pltbrowser-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 STARGATE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ pltbrowser