# 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:** 6

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 20, 2023, 9:36am UTC](https://root-forum.cern.ch/t/how-to-set-x-axis-range-after-using-setndivisions/57597/6 "2023-12-20T09:36:02Z")

</div>

> [@How to set ranges on axis?](https://root-forum.cern.ch/t/how-to-set-ranges-on-axis/28254):
>
> The viewing range for a histogram axis can be set from bin ifirst to ilast using the method TAxis::SetRange(ifirst, ilast). Example (hpxpy is a 2D histogram): { TFile f("hsimple.root"); hpxpy-\>Draw("colz"); hpxpy-\>GetYaxis()-\>SetRange(22,23); hpxpy-\>GetXaxis()-\>SetRange(18,19); } Sometimes it is more convenient to set this range using “User’s Coordinates” (axis values) rather than bin numbers. To do that one should use TAxis::SetRangeUser(ufirst, ulast). This method computes the cl…

[https://root.cern/doc/master/classTAttAxis.html#ae3067b6d4218970d09418291cbd84084](https://root.cern/doc/master/classTAttAxis.html#ae3067b6d4218970d09418291cbd84084)

---

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