Skip to main content

figure-gate

CI PyPI conda-forge Docs

Two scripts that read a built matplotlib figure and report which gates it fails, and a third that answers the rows that failed. audit(fig) returns (ok, rows), 21 rows, one per gate, each a (label, status, detail) triple where status is True, False, or "warn". check(colors) gates a palette the same way in 5 rows and returns the same shape. suggest(rows) turns the rows that did not pass into remedies, in the order the gates reported them. Every threshold is a module-level constant you can read and change.

There is also an Agent Skill wrapper that applies the same checks when Claude Code builds a figure.

git clone https://github.com/narenp12/figure-gate && cd figure-gate
python skill/scripts/check_palette.py "#E69F00,#56B4E9,#009E73" --pairs all
python skill/scripts/check_figure.py     # self-test on a broken figure

Validation loss against training epoch for three optimisers over 12 epochs. All three fall; the Bayesian run reaches 0.12 by epoch 6 and 0.02 by epoch 12, while the baseline is still at 0.25 at epoch 12.

python examples/demo.py builds that figure and audits it, and python examples/gallery.py covers the harder forms. Writing those eleven found seven defects in the checks themselves.

Documentation

Everything below the quickstart lives on the docs site:

  • Getting started: install or vendor, the two settings that need your document's values, and the code to call.
  • The gates: what each row measures, its threshold, and what a passing run does not mean.
  • The style guide: the measurement behind each threshold, and the rules tried and reverted.
  • Choosing a form: the decision no styling rule rescues.
  • API reference: signatures and defaults, generated from the scripts when the site builds.
uv add figure-gate          # or: conda install -c conda-forge figure-gate
from figure_gate import check_figure as cf

Copying the files into your own project is the other route, and the default one the docs teach; vendored, the import is import check_figure.

Where this sits

Prescriptive style sheets already exist and are good: SciencePlots and LovelyPlots for journal looks, tueplots and mpl_sizes for exact conference sizing. Accessibility tooling exists too: matplotalt generates alt text, Chart4Blind converts a chart image into an accessible one, contrast reporters check colors in isolation.

Each of those acts before or beside the figure. None of them reads the built result and reports what it fails, which is the only thing here, so a style sheet and this are complementary: set defaults with one, verify them with the other.

What the API promises

The public API is every name without a leading underscore in check_figure.py, check_palette.py and suggest_fixes.py. That is broader than the handful you would guess, and it is deliberately the same set the release gate compares, so the statement and the enforcement cannot drift apart.

Below 1.0, a minor bump may break it. Every break is named in the changelog under its release heading, and no change reaches main whose ## Unreleased section fails to name what moved: CI runs audit_api.py against the last tag on every pull request, and a symbol that changed without being written down fails the build.

The number of rows is not part of the contract. The shape is: audit returns (ok, rows), each row a (label, status, detail) triple whose status is True, False or "warn", and check returns the same shape. Gates get added; check_banking arrived after 0.6.0 and moved the count.

What is not enforced is the sentence rather than the symbol. The gate checks that a changed name appears in ## Unreleased next to a word admitting a change. It cannot check that the sentence describes the change accurately.

Contributing

New gates are welcome at the bar the project holds itself to: a test proving the gate fails on a figure with that defect, a test proving it does not over-fire on the nearest legitimate case, and a note naming the real failure that motivated it. See CONTRIBUTING.md and SECURITY.md.

License

MIT, see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

figure_gate-0.7.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figure_gate-0.7.0-py3-none-any.whl (72.2 kB view details)

Uploaded Python 3

File details

Details for the file figure_gate-0.7.0.tar.gz.

File metadata

  • Download URL: figure_gate-0.7.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for figure_gate-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e4930904c3653c08318e11b6d74972621bba6103746043ea31c3e528edff7656
MD5 c827c81ca4dfb2655a929b11c30bb94b
BLAKE2b-256 4a59926b45a36b8504dab7b7745df8067fcb28284a7ba68e404b76e08bae80f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for figure_gate-0.7.0.tar.gz:

Publisher: release.yml on narenp12/figure-gate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file figure_gate-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: figure_gate-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 72.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for figure_gate-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e7704ffb7e1afdcd762343eb2b92072c91a509965fc231e61284bdda89d0802
MD5 4ae46132f9b49e376849fee8825baf6a
BLAKE2b-256 1d98bee72c68299e4b148fa6bd492bb65cc2a6873f9ac7b7175a3d5cf95d3a39

See more details on using hashes here.

Provenance

The following attestation bundles were made for figure_gate-0.7.0-py3-none-any.whl:

Publisher: release.yml on narenp12/figure-gate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

2 files

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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