# How to get maximum X range value

**URL:** <https://root-forum.cern.ch/t/how-to-get-maximum-x-range-value/51068>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [August 4, 2022, 1:17pm UTC](https://root-forum.cern.ch/t/how-to-get-maximum-x-range-value/51068 "2022-08-04T13:17:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John2](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/f0a364/32.png) [@John2](https://root-forum.cern.ch/u/John2)\
**Post date:** [August 4, 2022, 1:17pm UTC](https://root-forum.cern.ch/t/how-to-get-maximum-x-range-value/51068/1 "2022-08-04T13:17:59Z")

</div>

Hi Rooters,  
I was wondering if there is a way to set maximum X range of the histo from the data automatically?  
The Histogram class:  
TH1D \*h1 = new TH1D(“h1”,“”,100,0,100); takes value of xmin and xmax and these values are user defined. Is there a way that it takes maximum X value automatically looking into the data ? Also what if I want to know what is the maximum X value which is fill in h1 ?

---

<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:** [August 4, 2022, 1:47pm UTC](https://root-forum.cern.ch/t/how-to-get-maximum-x-range-value/51068/2 "2022-08-04T13:47:59Z")

</div>

[TH1 → Histograms with automatic bins](https://root.cern/doc/master/classTH1.html#auto-bin)
