# Set axis range on THStack

**URL:** <https://root-forum.cern.ch/t/set-axis-range-on-thstack/42436>\
**Category:** Newbie\
**Created:** [November 25, 2020, 5:59am UTC](https://root-forum.cern.ch/t/set-axis-range-on-thstack/42436 "2020-11-25T05:59:24Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 26, 2020, 3:48am UTC](https://root-forum.cern.ch/t/set-axis-range-on-thstack/42436/3 "2020-11-26T03:48:34Z")

</div>

i followed this thread [Get local maximum when using THStack](https://root-forum.cern.ch/t/get-local-maximum-when-using-thstack/27361)  
and added

```auto
printf("GlobalMaximum: %f\n",hs->GetMaximum());
  
  TH1 *h = ((TH1*)(hs->GetStack()->Last()));
  
  h->GetXaxis()->SetRangeUser(0,100000);
  printf("LocalMaximum: %f\n",h->GetMaximum());

```

it works thanks

---

_[View the full topic](https://root-forum.cern.ch/t/set-axis-range-on-thstack/42436)._
