# Set User range on TGraph not working for x-axis , but OK for y-axis

**URL:** <https://root-forum.cern.ch/t/set-user-range-on-tgraph-not-working-for-x-axis-but-ok-for-y-axis/60668>\
**Category:** Newbie\
**Created:** [September 1, 2024, 9:17pm UTC](https://root-forum.cern.ch/t/set-user-range-on-tgraph-not-working-for-x-axis-but-ok-for-y-axis/60668 "2024-09-01T21:17:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [September 2, 2024, 5:48am UTC](https://root-forum.cern.ch/t/set-user-range-on-tgraph-not-working-for-x-axis-but-ok-for-y-axis/60668/2 "2024-09-02T05:48:58Z")

</div>

Probably your limits are larger than the values in TGraph, and SetRangeUser cannot go “outside” those values. In that case, try with SetLimits instead (note that this is ok for TGraph, not so much for histograms). See

> [@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…

and

> [@Draw TH1D for larger range](https://root-forum.cern.ch/t/draw-th1d-for-larger-range/55800):
>
> I have a th1d whose range is -10,10 but i want to plot -15,15 SetRangeUser(-15,15) draw the th1d for -10,10 any solution ? ROOT Version: 6.24.00 (conda\_forge) Platform: ubuntu20.04 (wsl) Compiler: gcc9

---

_[View the full topic](https://root-forum.cern.ch/t/set-user-range-on-tgraph-not-working-for-x-axis-but-ok-for-y-axis/60668)._
