# How to set X axis range after using SetNdivisions?

**URL:** <https://root-forum.cern.ch/t/how-to-set-x-axis-range-after-using-setndivisions/57597>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [December 19, 2023, 11:26am UTC](https://root-forum.cern.ch/t/how-to-set-x-axis-range-after-using-setndivisions/57597 "2023-12-19T11:26:58Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [December 20, 2023, 12:06pm UTC](https://root-forum.cern.ch/t/how-to-set-x-axis-range-after-using-setndivisions/57597/8 "2023-12-20T12:06:22Z")

</div>

Hi,

just to be clear: the `TAttAxis::SetNdivisions` has nothing to do with your problem. In [your previous post](https://root-forum.cern.ch/t/how-to-draw-a-bar-chart/57587) 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](https://root.cern.ch/root/html534/guides/users-guide/Histograms.html#constant-or-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`.

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-set-x-axis-range-after-using-setndivisions/57597)._
