Skip to main content

lusca

Python PyPI - Version CI Ruff

pip install lusca

lusca is a Python library for creating reproducible matplotlib figures using Jupyter magic commands. You often want to use Jupyter for experiments without rerunning the entire notebook to recreate a plot, and saving data alongside figures is essential for artifact generation and reproducibility.


%%mplfreeze

%%mplfreeze <name> [vars ...] [--outdir DIR]
  • <name>: Base name for outputs (folder + files).
  • [vars ...]: Variable names to save into the NPZ file.
  • [--outdir DIR]: Parent output directory (default: docs/figs).

The magic command:

  • Captures the data used in your plots and saves it in a compressed NPZ file.
  • Exports your figures in PDF, PNG, and SVG.
  • Generates a minimal standalone script that reproduces the figure.
  • Snapshots Python/package versions and the git commit into <name>.meta.json.
  • Statically checks the cell for unsaved free names before writing anything, then runs the generated replot in a subprocess to confirm the bundle actually reproduces the figure - if %%mplfreeze succeeds, the replot is guaranteed to work.
  • Applies lusca's built-in stylesheet.

Example

import matplotlib.pyplot as plt
import numpy as np
import lusca
%load_ext lusca
x_data = np.linspace(-10, 10, 100)
sine = np.sin(x_data)
cosine = np.cos(x_data)
%%mplfreeze trig_demo x_data sine cosine
with plt.style.context("lusca"):
    fig, ax = plt.subplots(1, 1, figsize=(3.5, 2.6), sharey=True)
    ax.plot(x_data, sine, label="Sine")
    ax.plot(x_data, cosine, label="Cosine")
    plt.show()

An example notebook is available in src/demo.ipynb. Generated plots are saved under docs/figs/:

name_stamp/
    name.npz             # saved variables
    name.pdf             # exported figure
    name.png
    name.svg
    name.meta.json       # python/package versions + git commit
    replot_name.py       # standalone replot script

Metadata

Release files for lusca 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lusca 0.1.4
File Size Uploaded
lusca-0.1.4.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lusca 0.1.4
File Interpreter ABI Platform
lusca-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 27.1 kB

Release files / lusca-0.1.4.tar.gz

Download URL lusca-0.1.4.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0e6cdb78a310b5bbec1ca98a1ddb6a2e33b8de9575148105dc63818f5703183f
BLAKE2b-256 checksum
How to use checksums
20d9f0f9ff19071cf0e0f453427eec01b35a24eca415ad538be7167008c4c793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / lusca-0.1.4-py3-none-any.whl

Download URL lusca-0.1.4-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19fe2c0fe197db035be83f9db890bc0a9846d3e65faffe400aa5db7954542afe
BLAKE2b-256 checksum
How to use checksums
9a0f1afa8d85c7cbf74ff4866c4208dd8696db7a3bfac217a16880767a499b17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page