Add global title to a root canvas

Hi everyone, needless to say, I’m very new to ROOT.

I’m trying to plot a canvas with divide (3,2) with a global title/heading to the canvas. I haven’t found an appropriate solution to add the title to a canvas (NOT to the individual plots). Thus, would be of great help if you have any suggestions. Thanks.


  TCanvas *c = new TCanvas("C","canvas",600,800);
  TLatex *lat = new TLatex(.4,.95,"canvas title");
  lat->Draw();  // drawn on canvas

  TH1F *h = new TH1F("h","histo",10,1,10);

  TPad *p1 = new TPad("p1","top",0,0.45,1,0.9); // xlow,yloy, xup,yup
  TPad *p2 = new TPad("p2","bottom",0,0,1,0.45);


  c->cd();  // to draw p2 on c, not inside p1



Basically, do your own pads (instead of using TCanvas::Divide) leaving space on the canvas for the text that you want to draw on the canvas; in this example the pads only go up to 90% of the canvas height. There are other ways; for instance you could use divide but making some extra space inside the top pad (with gPad->SetTopMargin(somevalue)) and then drawing the text on that pad (around y=0.95 or so).

1 Like

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