How to insert TLatex "above" TPad

Hello,

I have a very simple problem, but am not able to figure out an elegant solution.

Attached I have a plot (test.png) , which shows a TCanvas with 6 pads.
I’ve written a script (test.C) and attached it as well.

What I would like to do is :

  • Add a TLatex as a headline above to top 3 pads, to serve as the headline
    for all 6 pads. (TLatex in the script file)

  • Add a TLegend also above ( if possible in between the top and bottom pads)
    I just need one TLegend object, since all the markers etc. are the same anyway. (TLegend file in the script file)

Thanks in advance,
Sascha Falahat



test.C (6.26 KB)

Use the normalized coordinates:

  TLatex *   tex = new TLatex(0.5,0.5,"TEXT");
   tex->SetNDC();

Thanks for the reply.

But I am already doing right after the TLatex definition :

t->SetNDC(kTRUE);

and also tried your suggestion, but that does not work…

I attached a plot, which I changed by hand to show what I mean.


{
        TCanvas *c = new TCanvas("c","c");
        TF1 f1("f1","x",-1,1);
        TF1 f2("f2","x*x",-1,1);
        TF1 f3("f3","x*x*x",-1,1);
        TF1 f4("f4","x*x*x*x",-1,1);
        c->Divide(2,2);
        c->cd(1); f1.Draw();
        c->cd(2); f2.Draw();
        c->cd(3); f3.Draw();
        c->cd(4); f4.Draw();

        c->cd(0);
        TPad p("p","p",0,0,1,1); p.Draw(); p->cd();
        p->SetFillStyle(0);
        TLatex t1(.5,.95,"TITLE HERE");
        TLatex t2(.5,.5,"LEGEND HERE");
        t1.SetTextAlign(21); t1.SetNDC(); t1.Draw();
        t2.SetTextAlign(21); t2.SetNDC(); t2.Draw();
}

Thousand thanks!