Histogram title font pt. XXVIII

This was asked before, but I didn’t find a clear answer: Is it possible to modify the font of a histogram title non-interactively?

I tried to set

my_style->SetLabelFont(132, “xyz”);
my_style->SetStatFont(132);
my_style->SetTitleFont(132, “xyz”);
my_style->SetTextFont(132);

but the title still is drawn with the standard font (the axis and stats title is not).

Also I didn’t manage to catch the title Pave with some

gPad->GetPrimitive(…),

because apparently it’s drawn later, at program ending or so, I don’t know.

Is it possible or not?

Thanks a lot, Stefan

Hi Stefan,
see “Graphical Containers: Canvas and Pad” in UserGuide (p. 101)

{
  TH1F *h1 = new TH1F("h1","histo title",10,0,10);
  h1->Draw();
  gPad->Update();
  //  gPad->GetListOfPrimitives()->ls();
  TPaveText *pt = (TPaveText*)(gPad->GetPrimitive("title"));
  pt->SetTextColor(4);
  pt->SetTextFont(132);
  gPad->Modified();
}

Jan

Wow, that works, great!

Thanks so much!

Note that when you modify a Pad interactively, you can save the result as a “.C” macro (from the “File” menu). Then, looking at this script, you can see how to to same same in a non interactive way. This is a good way to learn how to change the various ROOT settings.