Rotate label of a TH1D


ROOT Version: 6.08.06-c8fb4
Platform: lxplus machines
Compiler: x86_64-slc6-gcc62-opt


Dear ROOT experts,
I am drawing a TH1D and I have defined x-labels with :

hist.GetXaxis().SetBinLabel(i_bin,my_string)

Then when I look at the plot, I see several labels overlapping and I would like to play with the angle of the label to avoid such overlaps.
After several tests of things found in the TAxis class or google, I am not able to modify the angle with

hist.GetXaxis().ChangeLabel(i_bin, -60., -1., -1, -1, -1, my_string)

(I see no changes in the display)
and I am not happy with the display I get from

h.LabelsOption(ā€œvā€)

What is the solution to my problem ?
Cheers, David.


root [0] auto h = new TH1D("h","h",10,0.,1.)
(TH1D *) @0x7ffeef30a798
root [1] h->Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [2] h->GetXaxis()->ChangeLabel(2,30,-1,-1,-1,-1,"Label with angle")
root [3] gPad->Update(); gPad->Modified();

It seems that I have a conflict when using

hist.GetXaxis().SetBinLabel(i_bin,my_str)
hist.GetXaxis().ChangeLabel(i_bin, -60., -1., -1, -1, -1, my_string)

if I use the ChangeLabel() alone I can rotate. But when both SetBinLabel() and ChangeLabel() are used, the ChangeLabel() is not applied.
I can close this ticket.
Thanks for your help.

Ah yes that could be. Change labels apply on numerical axis only.

I understand. Good to know. Thanks again.

It is simply not implemented. It could be if there is some real need.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.