I would like to make a very large title on my histogram such that it can be well read. But I do not seem to succeed. I have tried the methods SetTitleSize, but I see no effect (I call this before drawing).
With the mouse on the canvas, I right click on the title, and I see that is an TPaveText object. But I cannot locate this object as member of the TH1F (or one of the parent objects).
With the mouse I can easily resize the title (pave). Which methods are called there? How could I set those myself in a batch job?
You could save the source of your histogram as *.C file and have a look
how the title is generated. For example:
TPaveText *pt = new TPaveText(0.01,0.945,0.684118,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(2);
pt->SetFillColor(19);
text = pt->AddText("Summ of all invariant mass differences");
pt->Draw();
So you can see that you should get the object “title” after the drawing
and change its properties.
As indicated by Sergei, you can generate the code corresponding to what you have in the canvas.
Note that you can change interactively the size of the box title with the mouse.
If you want to change teh default title box size, see the class TStyle
void SetTitleX(Float_t x=0) {fTitleX=x;}
void SetTitleY(Float_t y=0.985) {fTitleY=y;}
void SetTitleW(Float_t w=0) {fTitleW=w;}
void SetTitleH(Float_t h=0) {fTitleH=h;}
Thanks for the replies, but unfortunately they are too complicated or expertive because I don’t understand.
Sergei, when I look at the code of TH1(F) or one of the parent classes, I do not find the creation of a TPaveText that subsequently is added as title box to the histogram. Trying to trace it through the TH1::Draw() method but I get wound up in gPads and TPainters?
Neither am I able to get the object “title” through the memberfunction FindObject() of TNamed. With the mouse I find out that the name of the TPaveObject::title is `title’. Then I type in CINT: h1->GetObject(“title”), which returns a 0x0 pointer (h1 is a TH1F). So this is not the way neither.
The GetTitle() returns the name only, the SetTitleSize() has no effect at all(?), before or after drawing. I wouldn’t know how to retrieve the title box otherwise, let alone how to add it again when modified to my needs.
Rene, I see the methods you mention in the TStyle class. But so long as I do not have an object of this type I cannot change it, and, as said, add it again as the title box.
Well, I hope you see what I do not see and I hope it is simple.
Well, just to let you know the score on this one: I can draw a TPaveText and just put it over the original title box and that will do. Directly trying to manipulate the title box has resulted in nothing but seg faults.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 18887)]
0x43ea210f in TH1::~TH1 () from /products/ROOT/3.10_03/gcc-2.95.3/root/lib/libHist.so
Do I have to delete anything that gStyle creates?
I make several histograms and only wrote once the gStyle commands.