Problem drawing multiple plots with same y-axis

Hi,
I am trying to plot multiple plots (in individual pads) which all share the same y-axis, so I see only the numbers on the y-axis on the far left. I have two problems. 1) All the text in the plot on the first pad is larger than on the other pads. 2) I can’t see all of the axis title on the y-axis, however if I try SetLeftMargin to make more room it changes only the width of the left most pad. Here is an example…

TH1D *h1 = new TH1D("h1","",100,-1,1); TH1D *h2 = new TH1D("h2","",100,-1,1); TH1D *h3 = new TH1D("h3","",100,-1,1); h1->FillRandom("gaus",10000); h2->FillRandom("gaus",20000); h3->FillRandom("gaus",30000); TCanvas *can = new TCanvas(); h1->GetYaxis()->SetTitle("Y-AXIS"); h1->GetYaxis()->SetRangeUser(0,500); h2->GetYaxis()->SetRangeUser(0,500); h3->GetYaxis()->SetRangeUser(0,500); TLatex *tex = new TLatex(-0.5,450,"#frac{1}{2}=0.5"); tex->SetTextSize(0.08); can->Divide(3,1,0,0); can->cd(1); h1->Draw(); tex->Draw(); can->cd(2); h2->Draw(); tex->Draw(); can->cd(3); h3->Draw(); tex->Draw();
Cheers.

I can suggest you the attached macro.
div2.C (1.55 KB)

Thanks that is nice, but I still have the problem with the different sized texts, both on the axes and a TLatex. I have attached an example.
div2_B.C (1.64 KB)
kt.pdf (27 KB)

Do:

   TLatex *tex = new TLatex(0.1,0.8,"TLATEX");
   tex->SetTextFont(23);
   tex->SetTextSize(12);

See the explanation here:
root.cern.ch/root/html/TAttText.html#T4

1 Like