Dear ROOT Talk,
I seem to be having problems alphabetically sorting alphanumeric labels in 2-D histograms.
I can get it to work fine for 1-D histograms, but not for 2-D histograms.
I’m using ROOT version 5.34.10.
Working example for 1-D histogram case:
void test1D()
{
char x[8];
TTree *t = new TTree();
t->Branch("x", x, "x[8]/C");
strcpy(x, "b");
t->Fill();
strcpy(x, "b");
t->Fill();
strcpy(x, "a");
t->Fill();
t->Draw("x>>hist", "", "goff");
TH1F *h = (TH1F*)gDirectory->Get("hist");
// Want to do alphabetical sorting of bin labels here.
h->LabelsOption("a", "X"); // This works.
h->Draw();
gPad->SaveAs("test1.eps");
delete t;
return;
}
Output: test1.eps (5.6 KB)
Not working example for 2-D case:
void test2D()
{
char x[8], y[8];
TTree *t = new TTree();
t->Branch("x", x, "x[8]/C");
t->Branch("y", y, "y[8]/C");
strcpy(x, "a");
strcpy(y, "a");
t->Fill();
strcpy(x, "c");
strcpy(y, "c");
t->Fill();
strcpy(x, "b");
strcpy(y, "b");
t->Fill();
t->Draw("y:x>>hist", "", "goff");
TH2F *h = (TH2F*)gDirectory->Get("hist");
// Want to do alphabetical sorting of bin labels here.
h->LabelsOption("a", "X"); // Neither of these two work when uncommented.
//h->LabelsOption("a", "Y");
h->Draw("colz");
gPad->SaveAs("test2.eps");
delete t;
return;
}
Output: test2.eps (7.36 KB)
Thank you,
Mich