How to set X axis range after using SetNdivisions?

Hi,

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.

1 Like