[hist] Add SetRefPad for consistent axis scaling#20763
Closed
JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
Closed
[hist] Add SetRefPad for consistent axis scaling#20763JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
Conversation
Test Results 6 files 6 suites 1d 2h 16m 50s ⏱️ Results for commit d1c338c. |
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.
This Pull request:
Implement opt-in Reference Pad scaling for TAxis (Fixes #20484)
Changes or fixes:
This PR addresses the long-standing issue of inconsistent axis title/label sizing and offsetting between pads of different sizes (e.g., in ratio plots), as described in issue #20484.
The Problem:
When creating canvases with split pads (e.g., 70/30 split), the default behavior scales text sizes relative to the pad height. This results in tiny, unreadable text in the smaller auxiliary pad, requiring users to manually tune
SetLabelSizeandSetTitleOffsetfor every axis.The Solution:
I have implemented an opt-in mechanism that allows an axis to use the dimensions of a "Reference Pad" for scaling calculations.
TAxis::SetRefPad(TVirtualPad *pad).fRefLengthtoTAxisto store the reference height (avoiding unsafe pointer storage).TGaxis::PaintAxisto check iffRefLength > 0.PaintAxiscalculates a scaling factor (fRefLength / currentPadHeight) and temporarily applies it tofLabelSize,fTitleSize,fTickSize,fLabelOffset, andfTitleOffsetusing anAttributeRestorer(RAII) pattern.Design Choice:
I chose an opt-in approach (
SetRefPad) rather than automatic scaling to preserve backward compatibility.Note:
I also investigated applying this fix to
TPaveStatsandTLegend, but due to the complexity of their internal layout logic, those changes are not included in this PR. This PR focuses strictly on fixing theTAxisconsistency, which was the core request of the issue.Verification Code
The following macro demonstrates the fix on a standard ratio plot.
(Please refer to the attached image for the output)
Checklist:
This PR fixes #20484