Kalam
Kalam

Plotpack

Figures that remember how they were made.

You open a figure from a paper you wrote last year and need to add one more point. The data is somewhere: an old notebook, a cluster you've lost access to, a folder called final_v3. It would be much easier if the figure just carried its data with it.

The proper fix is an image format that stores and describes its own data. I'm not here to invent one. Plotpack is the hacky version: PNG, SVG and PDF all have room for extra bytes, so it tucks the data, the script and the git commit inside the file. The image still opens anywhere as normal.

Then it does a bit more than that. Read a table back with one line of Python, unpack everything into a folder, or run plotpack inspect on any figure to see what's inside.

Install

uv add git+https://github.com/narunraman/plotpack

Use

import plotpack # instead of fig.savefigplotpack.save(fig, "fig3", data={"curves": df, "ci": ci}) # a year laterplotpack.read_table("figures/fig3.pdf", "ci")
plotpack unpack figures/fig3.pdf recovered/

What goes inside

data/The plotted tables, as CSV, .npy or JSON.
source/The script or notebook that made the figure.
manifestGit commit, Python packages, parameters and a hash of each table.

Only data and plain text, never pickled objects. Nothing inside is ever run.

The calling script or identified notebook is included by default. Notebook outputs and metadata are removed. Check the source and data before sharing, or omit source and git provenance with source=False, include_git=False.