Canvas

Hello,
I would like to have a Canvas divided for example in 4 pads
(c1->Divide(2,2,small,small) ). To have no space between the pads (can do it by playing with SelRightMargin(…) etc ).
If now I try to put the same axis title on the left margin (left top and bottom) or on the bottom margin (bottom left and right), the size of the 4 pads are not equal anymore.
So to do it in an "easy … :blush: " way, should I set the sizes of each pad by hand in ofder to take into acount the sizes of the borders, or there exist an easier way to do that ?
my second point is that if the sizes of the pads are too different, it also makes a difference in the text we put in the pads, so we also have to correct for that.

Thanks for your help !

Did you tried ${ROOTSYS}/tutorials/graphs/zones.C ?

Yes I already tried that but I changed it like:

{
   gROOT->Reset();
   TCanvas c1("c1","multipads",900,700);
   gStyle->SetOptStat(0);
   c1.Divide(2,2,0,0);
   TH2F h1("h1","test1",10,0,1,20,0,20);
   TH2F h2("h2","test2",10,0,1,20,0,100);
   TH2F h3("h3","test3",10,0,1,20,-1,1);
   TH2F h4("h4","test4",10,0,1,20,0,1000);
   
// Added part to increase the left and bottom border size (in order to put big axis titles )
   Float_t small = 1e-5;
   Float_t big = 0.30;
   
   c1->cd(1);
   gPad->SetTopMargin(small);
   gPad->SetLeftMargin(big);

   c1->cd(2);
   gPad->SetTopMargin(small);
   
   c1->cd(3);
   gPad->SetBottomMargin(big);
   gPad->SetLeftMargin(big);

   c1->cd(4);
   gPad->SetBottomMargin(big);


   
   c1.cd(1);
   gPad->SetTickx(2);
   h1.Draw();

   c1.cd(2);
   gPad->SetTickx(2);
   gPad->SetTicky(2);
   h2.GetYaxis()->SetLabelOffset(0.01);
   h2.Draw();
   
   c1.cd(3);
   h3.Draw();

   c1.cd(4);
   gPad->SetTicky(2);
   h4.Draw();
}      

if you try it you see that the 4 pads have now different size …
:cry:

one possible way:

{
   gStyle->SetPadLeftMargin(0.25);
   gStyle->SetPadRightMargin(0.25);
   TCanvas c1("c1","multipads",900,700);
   gStyle->SetOptStat(0);
   c1.Divide(2,2,0,0);
   TH2F h1("h1","test1",10,0,1,20,0,20);
   TH2F h2("h2","test2",10,0,1,20,0,100);
   TH2F h3("h3","test3",10,0,1,20,-1,1);
   TH2F h4("h4","test4",10,0,1,20,0,1000);
                                                                                
   c1.cd(1);
   gPad->SetTickx(2);
   h1.Draw();
                                                                                
   c1.cd(2);
   gPad->SetTickx(2);
   gPad->SetTicky(2);
   h2.GetYaxis()->SetLabelOffset(0.01);
   h2.Draw();
                                                                                
   c1.cd(3);
   h3.Draw();
                                                                                
   c1.cd(4);
   gPad->SetTicky(2);
   h4.Draw();
}

Of course the more flexible is to define the pads by their exact position.

Ok but unfortunately, by using that way (put the same margin to the
left and right) and/or (top and bottom) we considerably reduce the
space :confused: The ideal would have be to have a “superpad” which is
defined as a pad containing 4 subpads and to define the margins and
positions for that one.

The solution to use the exact position of
each pad is flexible, BUT, then we have a new problem there.
By changin the pad sizes like:
LeftPad_Ylength - Margin = RightPad_Ylength (for example).
But then the pads have different size ==> the text we will write on them will also have different size … :unamused: then we also will have to correct for that :exclamation: