# SetRangeUser is rebellious

**URL:** <https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286>\
**Category:** Newbie\
**Created:** [March 23, 2019, 9:18am UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286 "2019-03-23T09:18:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![berserker](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/berserker/32/17693_2.png) [@berserker](https://root-forum.cern.ch/u/berserker)\
**Post date:** [March 23, 2019, 9:18am UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/1 "2019-03-23T09:18:48Z")

</div>

I try to set Z axis limits for TH2 using `SetRangeUser`, but it does not respect the upper limit. Actual axis limit is slightly higher than what I set and depends on draw options! When I try to set it to `1.2`, what I get is something like `1.22` with `SURF1` drawing option and `1.26` with `E` option.  
[c1.C](https://root-forum.cern.ch/uploads/default/original/3X/8/7/874a1ea35a8131692f58dd7760a15cb2db8b2a35.C) (6.2 KB)

---

<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:** [March 23, 2019, 6:03pm UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/2 "2019-03-23T18:03:32Z")

</div>

Hi,  
try to use the SetMaximum method.

Cheers,  
Stefano

---

<div class="post-metadata">

**Author:** ![berserker](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/berserker/32/17693_2.png) [@berserker](https://root-forum.cern.ch/u/berserker)\
**Post date:** [March 23, 2019, 7:21pm UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/3 "2019-03-23T19:21:08Z")

</div>

`SetMaximum` demonstrates the same behavior.  
BTW, when I save the canvas to a `.C`-file, it has `->SetMaximum(1.2)` in it, even though the actual limit is as described in the first post.

---

<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:** [March 24, 2019, 10:26am UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/4 "2019-03-24T10:26:32Z")

</div>

Can you provide a minimal working example?  
I will try it on my laptop as soon as I can

S

---

<div class="post-metadata">

**Author:** ![berserker](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/berserker/32/17693_2.png) [@berserker](https://root-forum.cern.ch/u/berserker)\
**Post date:** [March 24, 2019, 7:52pm UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/5 "2019-03-24T19:52:50Z")

</div>

I’ve attached the `.C`-file to the first message.

---

<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:** [March 25, 2019, 9:29am UTC](https://root-forum.cern.ch/t/setrangeuser-is-rebellious/33286/6 "2019-03-25T09:29:37Z")

</div>

```auto
   gStyle->SetHistTopMargin(0.);
   hist->SetMinimum(0.8);
   hist->SetMaximum(1.2);

```
