Fix top & bottom text margins - #1054
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
The top & bottom text margins had been mistakenly scaled by the aspect-ratio of the figure.