I am trying to set the X-axis to start from 0 (instead of -0.5) however the SetRangeUser method doesn’t seem to respond. Can anyone please help me in this regard as to how can I change the range of the X-axis to start from 0?
In the context of the ROOT analysis framework, setting the X-axis range after using SetNdivisions can be a bit tricky, especially if you’re new to ROOT like I am.
I’ve tried to set the range of the X-axis. You typically use the method SetRangeUser(min, max) on the axis object. This is assuming you’re dealing with a histogram or a graph where you can access the axis via the histogram/graph object.
just to be clear: the TAttAxis::SetNdivisions has nothing to do with your problem. In your previous post you asked two different and independent things:
how to make bins centered around integers instead of half-integers;
how to get rid of labels with half-integers.
My reply to the first question was to shift the bins by 1/2 bin to the left, and my reply to your second question was to use the TAttAxis::SetNdivisions.
What you want to do now has only to do with shifting the bins to the left, and has nothing to do with TAttAxis::SetNdivisions. As @dastudillo pointed out, you cannot hide half of bin with TH1::SetRange or TH1::SetRangeUser. What you can do is to use a histogram with variable bin width instead, “splitting” your first bin (-0.5 < ID < +0.5) into two: -0.5 < ID < 0 and 0 < ID < +0.5. All other bins should be kept unchanged. Then you can “hide” your first bin (the one with -0.5 < ID < 0) using TH1::SetRange or TH1::SetRangeUser.