I want to change the labels of a TH2F’s y axis.
I attempt to do it this way:
c = ROOT.TCanvas()
f_in = ROOT.TFile("training.root","read")
CorrelationMatrixB = f_in.Get("Correlations/CorrelationMatrixB")
y = CorrelationMatrixB.GetYaxis()
But the result remains unchanged. I am, however, able to perform similar operations on the x axis.
Could you please let me know why this doesnt work with the y axis and how to change the labels?
Thank you in advance,
I guess your Y label are alphanumeric labels ? ChangeLabel does not work on them.
The Y and X labels are the same, and this worked on the X axis. So maybe thats not the problem?
Ah ok. so I am wrong. Can you post the root file ? I will look at it.
CorrelationMatrixB.root (5.5 KB)
I uploaded a root file with just the TH2F. Many thanks for taking a look at it.
With the following example I see what you described (ok on X but not on Y). I need to debug.
auto f_in = new TFile("CorrelationMatrixB.root");
TH2F* CorrelationMatrixB = (TH2F*)f_in->Get("CorrelationMatrixB");
TAxis *y = CorrelationMatrixB->GetYaxis();
TAxis *x = CorrelationMatrixB->GetXaxis();
SetBinLabel(14,"m(h")) instead of ChangeLabel.
I made a pull request to fix the ChangeLabel issue. It should work also.
Thanks to have seen it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.