Sometimes the Divide() method is not appropriate to divide a Canvas. Because of the left and right margins, all the pads do not have the same width and height. CanvasPartition does that properly. This example also ensure that the axis labels and titles have the same sizes and that the tick marks length is uniform. In addition, XtoPad and YtoPad allow to place graphics objects like text in the right place in each sub-pads.
{
if (C) delete C;
C =
new TCanvas(
"C",
"canvas",1024,640);
C->SetFillStyle(4000);
h =
new TH1F(
"histo",
"",100,-5.0,5.0);
h->FillRandom(
"gaus",10000);
h->GetXaxis()->SetTitle(
"x axis");
h->GetYaxis()->SetTitle(
"y axis");
C->cd(0);
pad[i][
j]->SetFillStyle(4000);
pad[i][
j]->SetFrameFillStyle(4000);
hFrame->SetMaximum(1.2*
h->GetMaximum());
hFrame->GetYaxis()->SetLabelFont(43);
hFrame->GetYaxis()->SetLabelSize(16);
hFrame->GetYaxis()->SetLabelOffset(0.02);
hFrame->GetYaxis()->SetTitleFont(43);
hFrame->GetYaxis()->SetTitleSize(16);
hFrame->GetYaxis()->SetTitleOffset(2);
hFrame->GetYaxis()->CenterTitle();
hFrame->GetYaxis()->SetNdivisions(505);
hFrame->GetXaxis()->SetLabelFont(43);
hFrame->GetXaxis()->SetLabelSize(16);
hFrame->GetXaxis()->SetLabelOffset(0.02);
hFrame->GetXaxis()->SetTitleFont(43);
hFrame->GetXaxis()->SetTitleSize(16);
hFrame->GetXaxis()->SetTitleOffset(1);
hFrame->GetXaxis()->CenterTitle();
hFrame->GetXaxis()->SetNdivisions(505);
text.DrawTextNDC(XtoPad(0.9), YtoPad(0.8),
gPad->GetName());
}
}
}
{
if (!C) return;
if (i==0) {
} else {
}
} else {
}
pad->SetFrameBorderMode(0);
}
}
}
{
double lm =
gPad->GetLeftMargin();
double rm =
gPad->GetRightMargin();
}
{
double tm =
gPad->GetTopMargin();
double bm =
gPad->GetBottomMargin();
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char text
R__EXTERN TStyle * gStyle
1-D histogram with a float per channel (see TH1 documentation)
The most important graphics class in the ROOT system.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Base class for several text objects.
constexpr Double_t C()
Velocity of light in .