# GetYaxis().SetRangeUser() does not work

**URL:** <https://root-forum.cern.ch/t/getyaxis-setrangeuser-does-not-work/55095>\
**Category:** ROOT\
**Created:** [May 30, 2023, 12:48pm UTC](https://root-forum.cern.ch/t/getyaxis-setrangeuser-does-not-work/55095 "2023-05-30T12:48:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [May 30, 2023, 12:48pm UTC](https://root-forum.cern.ch/t/getyaxis-setrangeuser-does-not-work/55095/1 "2023-05-30T12:48:58Z")

</div>

i have two TgraphErrors, with maximum y-values of 5 and 12 respectively.  
when i draw them in a divided canvas and set range of y-axis to (0,12), the first one still drawn for (0,5).  
any suggestion ?

* * *

_ROOT Version:_ 6.24.00 (conda\_forge)  
_Platform:_ ubuntu20.04 (wsl)  
_Compiler:_ gcc9

* * *

---

<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:** [May 30, 2023, 12:58pm UTC](https://root-forum.cern.ch/t/getyaxis-setrangeuser-does-not-work/55095/2 "2023-05-30T12:58:19Z")

</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…

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 13, 2023, 12:59pm UTC](https://root-forum.cern.ch/t/getyaxis-setrangeuser-does-not-work/55095/3 "2023-06-13T12:59:03Z")

</div>

Closed on June 13, 2023, 12:59pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
