I do not consider myself a newbie in ROOT but I somehow cannot crack the following, although I believe there’s an easy solutions to it.
I need to change the axis labels, but ONLY those that are displayed at the main division ticks(bin) and also I need to use the original value of the label at each main tick and derive the new one from it. The best way would be to loop over an array of labels. If I had the array I would then use the ChangeLabel(…) method where the new label is derived from the old one.
The problem is that invoking:
histo -> GetXaxis() -> GetLabels()
returns a nullptr all the time
A workaround would be using non-optimised axis divisions and do the changes then. This is however a bit inconvenient due to different axis ranges I need to process.
GetLabels returns nullptr because your labels are numeric. It returns the list of labels for the alphanumeric user defined labels.There is no direct way to get the value of a numeric label…So you will need to use the same algorithm used by TGaxis. ie:
root [0] .x AxisLabels.C
x1 = 0.214 x1o = 0.5
x2 = 2.6 x2o = 2.5
label number 1 is 0.5
label number 2 is 1
label number 3 is 1.5
label number 4 is 2
label number 5 is 2.5
root [1]