Is it possible to set the viewing range of a histogram with arbitray min/max values?
It seems that the min/max values can be only set to the bin edges.
I want to set the ranges of two or more histograms to the exactly same values for comparison.
Is it REALLY possible to set an arbitrary viewing range?
I mean, I want to set the xmin/xmax to the value other than bin edges, but as shown in the example below, the xmin/xmax seem to be forced to be bin edges.
root  TH1F h("h", "test", 5, 0, 5)
root  h.Draw()
root  h.GetXaxis()->SetRangeUser(0.5, 4.2)
root  gPad->Modified() // !! viewing range does not change!!
What I want to do is to set the viewing ranges of two histograms with different binning to the same for easy comparison.
When calling SetRangeUser, ROOT calculates the bin number that includes the extreme values. It cannot do anything else.
If what you want to do is simply to set the pad range, you can for example use TPad::DrawFrame
OK this second problem has nothing to do with your original posting.
Please be specific when posting to this site.
In particular could you post a working script showing the problem with option “cont” ?
One more remark: Given the fact that you store your data in bins, it is obvious that ROOT cannot create energy as it ignores the internal distribution in your bins at the boundaries.
It does relate closely with the first post.
I take it the solution you wrote is to set the viewing range by first calling TPad::DrawFrame(xmin, ymin, xmax, ymax) and then overlay the histogram with “same” option as below:
root TH1F h("h", "test", 5, 0, 5);
root gPad->DrawFrame(0.5, 4.2);
But this does not work for a 2D histogram plotted with “cont4” option.
Please try the attached script to see this.
One more remark: Given the fact that you store your data in bins, it is obvious that ROOT cannot create energy as it ignores the internal distribution in your bins at the boundaries. [/quote]
I can understand that, but is it very difficult to just limt the “visible” area to a given range?
I guess that showing multiple histograms with a common range is a common requirement in reports or papers…