Draw TH1D for larger range

I have a th1d whose range is -10,10
but i want to plot -15,15
SetRangeUser(-15,15) draw the th1d for -10,10
any solution ?

ROOT Version: 6.24.00 (conda_forge)
Platform: ubuntu20.04 (wsl)
Compiler: gcc9

The only solution is to first define an empty histogram from -15 to 15 and draw it first.

Then you plot your original histogram using Draw(“same”)

(probably you then need to adjust the Y zoom at the end)

Hi,

try to use h->GetXaxis()->SetLimits(-15,15) instead of h->SetRangeUser(-15,15).

Best,
Klaus

But doesn’t SetLimits change the x-data itself, rather than the zoom?

Oh indeed, you are right!

I just used SetLimits up to now to force the range of the histogram from a TGraph. There you don’t care, since the data is stored in TGraph.

Yeppp, SetLimits is one of those terrifying ROOT functions that does one thing for TGraph and another for TH1…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.