Re: setrange of x-axis

From: Nicholas Devenish <misnomer_at_gmail.com>
Date: Thu, 21 Jul 2011 12:19:29 +0100


On Thu, Jul 21, 2011 at 9:20 AM, Olivier Couet <Olivier.Couet_at_cern.ch> wrote:
> The doc says that SetLimits defines the limit of the axis (min and max),
> whereas SetRange and SetRangeUser define the viewing range within these
> limits. I do not see what you could says more ?

I'm sorry, but a function called "SetLimits" with the documentation "Set the axis limits" can never be classed as good documentation. The function "Set" that it links is itself unclear, and says that it *initialises* the axis (so no suggestion of the effect of an existing axis). I appreciate how simple the SetLimits function is, but to actually work out what it means requires much digging through the Axis/histogram code. And yes, with what is there, the description appears to give identical functionality to SetRangeUser.

The documentation gives absolutely no indication what the end result will be after the action. I tested several histograms; with fixed bins it appeared to scale the whole histogram, whereas with variable bins it appeared to scale the last bin in data (when querying with GetBinLowEdge) but drew with the original scales.

For instance,
Double_t lowedges [] = {0, 1, 2, 4, 8, 100} TH1D test4("test3", "test3", 5, lowedges)

test4.FillRandom("pol0")
test4.Draw()
test4.GetBinLowEdge(6)
// (const Double_t)1.00000000000000000e+02

Draws the histogram as expected. Then:

test4.GetXaxis()->SetLimits(0,10)
test4.Draw()
test4.GetBinLowEdge(6)
// (const Double_t)1.00000000000000000e+01

Draws the histogram exactly the same as before, but the data interface no longer corresponds with the visual. Only the last bin seems to have been scaled.

Amusingly, setting the axis limits below the actual histogram width seemingly gives out-of-order histogram bins: test4.GetXaxis()->SetLimits(0,7)
test4.GetBinLowEdge(5)

// (const Double_t)8.00000000000000000e+00
test4.GetBinLowEdge(6)
// (const Double_t)7.00000000000000000e+00

I don't expect any of this to be fixed - after all, it is being used in a strange way, but it shows how the documentation gives no indication of the result of performing an action.

Nick Received on Thu Jul 21 2011 - 13:19:43 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 21 2011 - 17:50:02 CEST