void error()
{
TCanvas c(“c”, “c”, 800, 600);
// TH1 *h = c.DrawFrame(0.5, 0, 10.5, 10);
TH1F *h = new TH1F(“h”, “h”, 10, 0.5, 10.5);
h->GetYaxis()->SetRangeUser(0, 10);
TAxis *ax = h->GetXaxis();
ax->SetNdivisions(10, 0, 0, kTRUE);
for (int i=0; i<10; i++)
ax->SetBinLabel(i+1, Form("%d_%d", i, i+1));
h->SetStats(kFALSE);
h->Draw();
c.Modified();
c.SaveAs(“error.png”);
}
here is the code, if I draw with empty histogram, and then change its X-axis label, everything looks fine:
if I change h to TH1 frame, then I got something like this:
You can see that all labels curl up in the bottom left corner, I have no idea why so. Anybody can help? Thank you in advance.
Please read tips for efficient and successful posting and posting code
_ROOT Version: 6.16.00
_Platform: Ubuntu 20.04.2 LTS
_Compiler: gcc 9.3.0