# How to use SetRangeUser

**URL:** <https://root-forum.cern.ch/t/how-to-use-setrangeuser/26035>\
**Category:** ROOT\
**Created:** [August 27, 2017, 4:46pm UTC](https://root-forum.cern.ch/t/how-to-use-setrangeuser/26035 "2017-08-27T16:46:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 27, 2017, 5:50pm UTC](https://root-forum.cern.ch/t/how-to-use-setrangeuser/26035/2 "2017-08-27T17:50:58Z")

</div>

> [@SetAxisRange(0.0,1.0,"Y"); is ineffective](https://root-forum.cern.ch/t/setaxisrange-0-0-1-0-y-is-ineffective/14040/4):
>
> From my experience … for a TH1 I am usually using something like this: histo-\>Draw(); histo-\>SetAxisRange(xmin, xmax, “X”); histo-\>SetAxisRange(ymin, ymax, “Y”); histo-\>Draw(); // make sure it’s redrawn If I am dealing with a THStack of several TH1 histograms, I am usually using something like this: stack-\>Draw(“H”); stack-\>GetXaxis()-\>SetLimits(xmin, xmax); stack-\>SetMinimum(ymin); stack-\>SetMaximum(ymax); stack-\>Draw(“H”); // make sure it’s redrawn

> [@Palette on a TProfile2d](https://root-forum.cern.ch/t/palette-on-a-tprofile2d/14704/2):
>
> Try: h4bprof-\>SetAxisRange(8, 20, “Z”); and/or: h4bprof-\>GetZaxis()-\>SetRangeUser(8, 20); Actually, I believe this should work as well: h4bprof-\>SetMinimum(8); h4bprof-\>SetMaximum(20); See also: [url][SetAxisRange(0.0,1.0,“Y”); is ineffective](https://root-forum.cern.ch/t/setaxisrange-0-0-1-0-y-is-ineffective/14040/1) [url][Drawing a TGraphAsymmErrors](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/1) BTW. You have a typo in your “tree.c” file in line 356 … “SetMinimun” does NOT exist at all (note that the last character in this name is a “n” instead of a “m”) … I think that’s where your problem originates …

> [@SetRangeUser and SetTitle working with THStacks and TH1F obj](https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114/2):
>
> I once had similar problems. Here’s what I’ve found to be working (don’t ask me why, no idea). 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(…

> [@Plotting a portion of a histogram?](https://root-forum.cern.ch/t/plotting-a-portion-of-a-histogram/22053/2):
>
> { gStyle-\>SetOptFit(); TH1::SetDefaultSumw2(kTRUE); // ensure proper error propagation TH1D \*counts = new TH1D("counts", "full histogram", 100, -5, 5); // counts-\>Sumw2(kTRUE); // not needed if "TH1::SetDefaultSumw2" counts-\>FillRandom("gaus", 11000); TH1D \*bgcounts = new TH1D("bgcounts", "background", 100, -5, 5); // bgcounts-\>Sumw2(kTRUE); // not needed if "TH1::SetDefaultSumw2" bgcounts-\>FillRandom("gaus", 1000); TH1D \*noBgCounts = new TH1D(\*counts); // make a copy of "count…

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-use-setrangeuser/26035)._
