Skip to content

Conversation

@ferdymercury
Copy link
Collaborator

@ferdymercury ferdymercury commented Nov 3, 2025

This Pull request:

Changes or fixes:

Default drawing histogram option is to leave a YMARGIN range of 10% in YMAX. So if you call Unzoom, it was calling GetMaximum, which calculated the exact maximum, and then called SetMaximum, thus overwriting the stored value. Use instead GetMaximumStored to prevent recalculation if not set by user.

Also add sanity check before casting

Reproducer:

TH1F h("h", "", 100, 0, 10);
h->Fill(2);
h.Draw();
h.GetYaxis()->UnZoom(); // This zooms in rather than out.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

@ferdymercury ferdymercury requested a review from lmoneta as a code owner November 3, 2025 13:41
Default drawing histogram option is to leave a YMARGIN range of 10% in YMAX. So if you call Unzoom, it was calling GetMaximum, which calculated the exact maximum, and then called SetMaximum, thus overwriting the stored value. Use instead GetMaximumStored to prevent recalculation if not set by user.
@ferdymercury ferdymercury requested review from couet and linev November 3, 2025 13:43
@couet
Copy link
Member

couet commented Nov 3, 2025

Default drawing histogram option is to leave a YMARGIN range of 10% in YMAX.

it is not a fixed vaule of 10%: it can be set via TStyle::SetHisTopMargin and it can be 0.

@ferdymercury
Copy link
Collaborator Author

Default drawing histogram option is to leave a YMARGIN range of 10% in YMAX.

it is not a fixed vaule of 10%: it can be set via TStyle::SetHisTopMargin and it can be 0.

Thanks for the clarification. This does not change the underlying issue, the correct wording would be:

Default drawing histogram option is to leave a margin of X% in YMAX, where X is defined by TStyle::SetHistTopMargin.

When one clicks on "Unzoom", the x axis is "zoomed in", rather than 'kept as is' or zoomed out, which is quite counterintuitive.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit d51306a.

♻️ This comment has been updated with latest results.

thanks to silverweed
@couet couet assigned lmoneta and unassigned couet Nov 5, 2025
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.

4 participants