Repository navigation
feat(figure): add four-side outer margin to subplots (#311) - #312
Merged
Merged
Conversation
Constrained layout offers only symmetric w_pad/h_pad, so xpad=0/ypad=0 with crop=False leaves spines flush on the media box. The new margin (left, bottom, right, top) in points maps to the engine rect, coexists with inner pads, and is rejected under tight layout or when it covers the figure.
Owner
Author
|
Review 1 (requirements, API surface, compat, risk)
|
Owner
Author
|
Review 2 (complete diff, checks, secrets/generated scan)
|
Owner
Author
|
CI green on head 9225348: all required checks pass (tests 3.10/3.12, documentation incl. versioned build, format, audit, CodeQL). Ready to merge; awaiting maintainer approval. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #311.
Summary
gs.subplots(..., margin=(left, bottom, right, top))reserves figure-edge space outside the constrained layout, fixing spine clipping withxpad=0.0, ypad=0.0+crop=False. Pt values, fixed regardless ofunit; internally sets the enginerect.Changes
src/gsplot/_figure/layout.py:_marginvalidator (4-tuple, finite, non-negative); new parameter on all overloads + impl + signature fn + docstring; engine application with figure-covering and tight-layout rejection.tests/unit/test_layout_foundation.py: rect mapping + 4 rejection paths.tests/fixtures/reform/public-api-v1.json: regenerated (subplots signature/docstring only).docs/guides/publication.md,docs/project/requirements.md: margin rule.Compatibility classification
Additive: one optional parameter, default None preserves every existing call. No changes to pad/xpad semantics; no adapter needed (subplots is direct canonical).
Validation evidence
MPLBACKEND=Agg poetry run pytest -q tests: 509 passed.black,isort,mypy,pyright src/gsplot,pyright examples,compileall,check_architecture.py,check_docstrings.py: clean.sphinx-build -W -b html docs docs/_build/html: succeeded; no generated files in diff.pip-audit --local: environment-blocked (no PyPI network); no dependency change in this slice.Residual risks
layout='tight'+ margin raises by design (no rect support there).