Skip to content

Fix top & bottom text margins - #1054

Merged
has2k1 merged 6 commits into
mainfrom
fix-margins
Apr 19, 2026
Merged

Fix top & bottom text margins#1054
has2k1 merged 6 commits into
mainfrom
fix-margins

Conversation

@has2k1

@has2k1 has2k1 commented Apr 19, 2026

Copy link
Copy Markdown
Owner

The top & bottom text margins had been mistakenly scaled by the aspect-ratio of the figure.

has2k1 added 6 commits April 18, 2026 20:22
Replace the silent ZeroDivisionError suppression in margin.to() with
an explicit _is_setup flag. A margin must be attached to a themeable
in a theme (which calls setup()) before any unit conversion; calling
.to(...) earlier used to silently produce a margin with the new unit
label but unchanged numeric values.
Distinguish raw theme.getp("plot_margin_*") floats (fraction of width,
need F = W/H for vertical use) from margin.to("fig") values (already in
the correct per-edge fractional basis). The previous note described
only the former convention, which misled readers about margin.fig.
margin.setup() assigned themeable_name to self but the attribute was
never read anywhere in the repo, and element_text.setup() reassigned
m to the return value of m.setup(...) which is None. Both are no-ops
that only work because margin.setup mutates in place.
margin.to("fig") returns top/bottom values as fractions of figure
height already; the layout code was multiplying them by F = W/H a
second time, making vertical text margins grow with the aspect ratio.
Remove the extra * F on m.t / m.b in the top/bottom side-space
calculations in both plot and composition layouts. Regenerate
baseline images affected by the corrected spacing.
Trailing baseline regeneration from the layout change in 676964a.
@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.84%. Comparing base (6fb0180) to head (781f680).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1054   +/-   ##
=======================================
  Coverage   86.83%   86.84%           
=======================================
  Files         203      203           
  Lines       13789    13788    -1     
  Branches     1688     1689    +1     
=======================================
  Hits        11974    11974           
+ Misses       1266     1265    -1     
  Partials      549      549           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@has2k1
has2k1 merged commit 781f680 into main Apr 19, 2026
13 checks passed
@has2k1
has2k1 deleted the fix-margins branch April 19, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant