ROOT Version: 6.17/01
Platform: linuxx8664gcc
Compiler: gcc version 8.3.1 20190223
Hello,
I have a 1-Dimensional histogram, say h1 with bins going from 0 to 4000. The X-axis tick-mark labels are
in the interval of 1000 i.e. 0,1000,2000,3000,4000
Now, I rebin X-Axis using
h1->RebinX(10)
After this operation the X-axis tick-mark labels are still the same i.e. 0,1000,2000,3000,4000
I want these to change to 0,100,200,300,400 since the calibration of the axis is also changed now. I am not able to get this behaviour.
I tried to search for the answer on the ROOT Forum but the search did led to to relevant post. Also, I am sorry, if this sounds a very simple question.
Regards,
Ajay
Thank you very much! It is working!
But isn’t there a simple way to achieve it? We need this functionality quite frequently with different scaling factors. This means - I have to edit the macro everytime before using it. Isn’t it?
What I was doing was following:
root [0] .L ScaleAxes.cxx++
root [1] .L ../can2root_utils_cc.so //"can2root_utils.cc stores several macros
root [2] loadF("CtrdShftAna.root");
root [3] td662Vs377_278_bgsub->RebinX(10);
root [4] ScaleXaxis(td662Vs377_278_bgsub, ScaleX);
root [5] td662Vs377_278_bgsub->Draw();
root [6] td662Vs377_278_bgsub->ResetStats();
With the above I achieve what I wanted to by changing v = 10 * x + 100; to v = 0.1 * x + 100; in the original macro in Double_t ScaleX(Double_t x) function.
It would have been great to use a scaling factor at root [4] instead of using ScaleX.
I hope I was using it as it is intended.
With best regards,
Ajay
If the x-axis is a “fix bin size” one then this should be enough:
your_histogram->GetXaxis()->SetLimits(new_x_min, new_x_max);
your_histogram->ResetStats();
Perfect! This is what I was looking for. Thank you once again.