String label font size

Hi,

I am changing the bin label from numbers to strings. I copy a simple test macro below. How can I have the strings with the same font size as the numbers?

void test()
{
  gInterpreter->ExecuteMacro("PaperStyle.C");

  TH1F* hist1 = new TH1F("hist1", "", 5, -0.5, 4.5);
  TH1F* hist2 = new TH1F("hist2", "", 5, -0.5, 4.5);

  TCanvas* c1 = new TCanvas("c1", "c1");

  hist1->Draw();

  c1->SaveAs("number.png");

  TAxis* xaxis = hist2->GetXaxis();

  for (int i=1; i<=xaxis->GetNbins(); i++)
    xaxis->SetBinLabel(i, "qwerty");

  TCanvas* c2 = new TCanvas("c2", "c2");

  hist2->Draw();

  c2->SaveAs("strings.png");
}

Thanks,
Jonatan




In case of alphanumeric labels the label size is automatically adjust to make sure le labels do not overlap. Adjust the Y axis.

Thank you Olivier,

What do you mean by “adjust the Y axis”?

Best,
Jonatan

As the X-axis label size is automatic, you should change the Y labels axis size to have a size close to the one of the X axis

Can you provide an example?

Thanks!
Jonatan

histo->GetYaxis()->SetLabelSize(histo->GetXaxis()->GetLabelSize());