GUIBRUSHR.core.functions.figure_pickle module¶
Helpers to persist matplotlib figures for interactive reload in the GUI.
Heavy plots are rendered in headless background subprocesses that only write
PNG/PDF to disk, so the live matplotlib Figure never reaches the GUI process.
To restore zoom/pan, each subprocess dumps the figure next to its PNG with
dump_figure; MyFigure then loads it and embeds an interactive canvas
(falling back to the static PNG when the dump is absent or unreadable).
Kept dependency-light (only pickle / os) so subprocesses can import it
without pulling in the Tk backend.
- GUIBRUSHR.core.functions.figure_pickle.figpkl_path(png_path) str[source]¶
Return the figpkl path that sits next to
png_path.
- GUIBRUSHR.core.functions.figure_pickle.figs_path(pdf_path) str[source]¶
Return the multi-figure pickle path for a PDF (
.pdf->.figs.pkl).
- GUIBRUSHR.core.functions.figure_pickle.dump_figure(fig, png_path) None[source]¶
Pickle a matplotlib Figure next to its PNG for interactive reload.
Best-effort: any failure (an unpicklable figure, a read-only folder) is swallowed so it can never break the PNG/PDF generation that callers rely on.
- Parameters:
fig – The matplotlib Figure to persist.
png_path – Path of the PNG the figure was saved to; the pickle is written alongside it with the
.figpklsuffix.
- GUIBRUSHR.core.functions.figure_pickle.load_figure(png_path)[source]¶
Load a pickled figure for
png_pathif present, else returnNone.Best-effort: returns
Noneon a missing file or any unpickling error so the caller can fall back to the static image.
- GUIBRUSHR.core.functions.figure_pickle.save_figure_blobs(blobs, pdf_path) None[source]¶
Persist a list of already-pickled figure byte-blobs next to a PDF.
The on-disk
.figs.pklformat is a list ofpickle.dumps(figure)blobs. Storing bytes (rather than live figures) is deliberate: unpickling a figure re-registers it with pyplot’s figure manager, so a retained live copy would be wiped by a laterplt.clf()in the page-producing code. Bytes captured at draw time are an immutable snapshot, immune to that.Best-effort: any failure is swallowed so it can never break the PDF.