# SetRangeUser and SetTitle working with THStacks and TH1F obj

**URL:** <https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114>\
**Category:** ROOT\
**Created:** [March 22, 2011, 5:00pm UTC](https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114 "2011-03-22T17:00:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 22, 2011, 7:24pm UTC](https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114/2 "2011-03-22T19:24:20Z")

</div>

I once had similar problems. Here’s what I’ve found to be working (don’t ask me why, no idea).

```cpp
THStack *hs = (THStack *)0;
hs = new THStack(*hs_ORIG); // do not modify the "hs_ORIG" THStack, create a copy
hs->Draw("H NOSTACK");
hs->GetHistogram()->SetXTitle("My X Title");
hs->GetHistogram()->SetYTitle("My Y Title");
hs->GetXaxis()->SetTitleOffset(1.0);
hs->GetYaxis()->SetTitleOffset(1.5);
hs->GetYaxis()->CenterTitle(kTRUE);
hs->GetXaxis()->SetLimits(0, 10.001); // "xmin", "xmax"
hs->SetMinimum(1.95e8); // "ymin"
hs->SetMaximum(2.02e12); // "ymax"

```

```cpp
TH1 *h = (TH1 *)0;
h = ((TH1 *)(hs_ORIG->GetStack()->Last()))->DrawCopy("H"); // copy of the THStack "sum"
h->SetTitle("My Title");
h->SetLineColor(2);
h->SetAxisRange(0, 9.999, "X"); // "xmin", "xmax"
h->SetAxisRange(1, 1600e9, "Y"); // "ymin", "ymax"
h->Draw("H");

```

---

_[View the full topic](https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114)._
