# How to set axis range in my code?

**URL:** <https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030>\
**Category:** ROOT\
**Tags:** graphics, root\
**Created:** [November 8, 2023, 1:29pm UTC](https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030 "2023-11-08T13:29:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![songshusen](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@songshusen](https://root-forum.cern.ch/u/songshusen)\
**Post date:** [November 8, 2023, 1:29pm UTC](https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030/1 "2023-11-08T13:29:48Z")

</div>

* * *

_ROOT Version:_ 6.28  
_Platform:_ win10  
_Compiler:_ visual c++  
How to set axis range in my code?

 ![axis_range](https://root-forum.cern.ch/uploads/default/original/3X/e/6/e6d7aa5e737ffa6931e25620cb3c429bc3c9b89f.png)

* * *

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [November 8, 2023, 1:59pm UTC](https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030/2 "2023-11-08T13:59:01Z")

</div>

Hi,  
just before drawing in the canvas

```auto
graph->GetYaxis()->SetRangeUser(ymni,ymax)

```

And similarly on x axis

Best,  
Stefano

---

<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:** [November 8, 2023, 2:10pm UTC](https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030/3 "2023-11-08T14:10:48Z")

</div>

See also this HowTo: [How to set ranges on axis?](https://root-forum.cern.ch/t/how-to-set-ranges-on-axis/28254)

---

<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:** [November 22, 2023, 2:11pm UTC](https://root-forum.cern.ch/t/how-to-set-axis-range-in-my-code/57030/4 "2023-11-22T14:11:26Z")

</div>

Closed on November 22, 2023, 2:11pm UTC

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