root icon indicating copy to clipboard operation
root copied to clipboard

[hist] prevent Unzoom from Zooming in

Open ferdymercury opened this issue 1 month ago • 3 comments

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:

  • [x] tested changes locally
  • [ ] updated the docs (if necessary)

ferdymercury avatar Nov 03 '25 13:11 ferdymercury

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.

couet avatar Nov 03 '25 13:11 couet

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.

ferdymercury avatar Nov 03 '25 13:11 ferdymercury

Test Results

    20 files      20 suites   3d 7h 15m 22s ⏱️  3 780 tests  3 779 ✅ 0 💤 1 ❌ 73 854 runs  73 853 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit d51306aa.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Nov 03 '25 15:11 github-actions[bot]