How to set title for canvas with several pads

Hi,
I have a problem about setting the title for the plot.
I divide the canvas into 4 parts, and use three TPads to plot three histograms on it.
Then I cannot use “c->SetTitle()” to set a title for the whole plot.
Is there someone know how to do it?
Cheers,
Jennyr11.C (2.0 KB)

Try drawing TLatex text on a transparent pad covering the canvas. After you draw all your pads, do for instance:

   c1->cd();  // c1 is the TCanvas
   TPad *pad5 = new TPad("all","all",0,0,1,1);
   pad5->SetFillStyle(4000);  // transparent
   pad5->Draw();
   pad5->cd();
   TLatex *lat = new TLatex();
   lat->DrawLatexNDC(.4,.95,"My Title");
1 Like

OK, it works well. Thanks a lot for your kind help!

by the way, how to change the title size then? I tried lat->setTextSize(0.5), but it doesn’t work.

This works for me:

{
   TLatex *   tex = new TLatex(0.5,0.8,"My Title");
   tex->SetNDC();
   tex->SetTextSize(0.2);
   tex->Draw();
}

OK, it works now. I put the SetTextSize() after the Draw last time and so it didn’t work.
Thanks a lot : )

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