# Can't zoom in TH1D - x-axis region

**URL:** <https://root-forum.cern.ch/t/cant-zoom-in-th1d-x-axis-region/38998>\
**Category:** Newbie\
**Created:** [April 20, 2020, 1:30pm UTC](https://root-forum.cern.ch/t/cant-zoom-in-th1d-x-axis-region/38998 "2020-04-20T13:30:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcogobbo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@marcogobbo](https://root-forum.cern.ch/u/marcogobbo)\
**Post date:** [April 20, 2020, 1:30pm UTC](https://root-forum.cern.ch/t/cant-zoom-in-th1d-x-axis-region/38998/1 "2020-04-20T13:30:48Z")

</div>

Hi, I’m a student in physics and I have some trouble with my code. It works but when I change the value of limInf and limSup, the data doesn’t zoom into the range that I want, it resizes itself.  
I’m using

`histoHV->GetXaxis()->SetLimits(limInf,limSup);`

This pastebin(dot)com/KJAJgC5q is my entire code.

The two results:  
[graph\_HV2000 copia.pdf](https://root-forum.cern.ch/uploads/short-url/97HYaKVDtHFUYAR19LY9svro48I.pdf) (103.6 KB)  
[graph\_HV2000.pdf](https://root-forum.cern.ch/uploads/short-url/4SnoqXbSts2sLvo4mBKpBd9UPBv.pdf) (103.7 KB)

What I want is to zoom the region between 1200-1300 where I want to fit the max peak.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 20, 2020, 1:59pm UTC](https://root-forum.cern.ch/t/cant-zoom-in-th1d-x-axis-region/38998/2 "2020-04-20T13:59:30Z")

</div>

[Try:  
 `histoHV->GetXaxis()->SetRangeUser(limInf, limSup);`  
or:  
 `histoHV->SetAxisRange(limInf, limSup, "X");`](https://root.cern.ch/how/how-set-ranges-axis)

Afterward, you may also need:  
`if (gPad) { gPad->Modified(); gPad->Update(); }`
