Titles disappear for font precision 3

Hi!

When I use font precision 3 (to give absolute font sizes), the title (of TH1Fs etc.) does no longer show up.

Here’s a quick example:

// -------- SET FONT --------

int font = 43;  // arial, precision 3

gStyle->SetTextFont(font);

gStyle->SetTitleFont(font, "");
gStyle->SetTitleFont(font, "x");
gStyle->SetTitleFont(font, "y");
gStyle->SetTitleFont(font, "z");

gStyle->SetLabelFont(font, "");
gStyle->SetLabelFont(font, "x");
gStyle->SetLabelFont(font, "y");
gStyle->SetLabelFont(font, "z");

gStyle->SetStatFont(font);
gStyle->SetLegendFont(font);

// -------- SET SIZE --------

int size_px = 13;

gStyle->SetTextSize(size_px);

gStyle->SetTitleSize(size_px, "");
gStyle->SetTitleSize(size_px, "x");
gStyle->SetTitleSize(size_px, "y");
gStyle->SetTitleSize(size_px, "z");

gStyle->SetLabelSize(size_px, "");
gStyle->SetLabelSize(size_px, "x");
gStyle->SetLabelSize(size_px, "y");
gStyle->SetLabelSize(size_px, "z");

gStyle->SetStatFontSize(size_px);
gStyle->SetLegendTextSize(size_px);

gStyle->SetTitleFontSize(size_px);

// -------- DRAW SOMETHING --------

auto h = new TH1F("h","test",100,-3,3);
h->FillRandom("gaus",3000);
h->Draw();

Am I doing something wrong?

Any help or just confirming that this is strange/ also happens with other ROOT versions would be much appreciated :slight_smile:

Best regards,
Kilian


_ROOT Version: _ 6.06/08
Platform: Linux version 4.13.0-45-generic 16.04.1-Ubuntu
Compiler: Not Provided


@couet It seems to me that there is a bug in the calculation of the “Y1” for the “TPaveText title” (in ROOT 5 and 6). From “c1->ls();”, one gets “Y1=-1495.495335” (another coordinates are o.k.). After running the “quick example” macro, try to execute:

gPad->Update(); ((TPaveText*)(gPad->GetPrimitive("title")))->SetY1(gPad->GetUymax()); gPad->Modified(); gPad->Update();

I see the problem too. I will check.

The following is enough to show the problem:

{
   int font = 43;  // arial, precision 3
   gStyle->SetTitleFont(font, "");

   int size_px = 13;
   gStyle->SetTitleSize(size_px, "");

   auto h = new TH1F("h","Title test",100,-3,3);
   h->FillRandom("gaus",3000);
   h->Draw();
}

@Wile_E_Coyote Thank you for your quick reply! Substituting gPad->GetUymax() for the y coordinate, ((TPaveText*) c1->GetPrimitive("title")))->SetY1(gPad->GetUymax()); c1->Modified(); c1->Update(); seems like a pretty stable workaround. Thank you!

@couet Thanks for confirming that!

Cheers,
Kilian

I am fixing this now. Right now the case of “pixel fonts” is ignored when painting the title.

This is now fixed in the ROOT master. Thanks for reporting.

Thank you for fixing this! :smile:

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