Hello everyone,
I am having issues in using two pads in one canvas.
-
Is there a way to have all texts with the same dimension, and not based on the ratio of canva the pad is occupying?
-
Why the label of the y-axis of the bottom plot is not aligned with the one of the top plot?
A snippet of my code:
def set_canvas_margins(canvas, left=0.15, right=0.02, top=0.02, bottom=0.15, plot_ylog=plot_ylog):
canvas.SetLeftMargin(left)
canvas.SetRightMargin(right)
canvas.SetTopMargin(top)
canvas.SetBottomMargin(bottom)
if plot_ylog:
canvas.SetLogy()
def set_frame_axis(frame, labelsize=labelsize_root, titlesize=titlesize_root, plot_ylog=plot_ylog):
frame.SetAxisRange(0.5 if plot_ylog else frame.GetMinimum()*1.2, frame.GetMaximum() * (3 if plot_ylog else 1.2), 'Y')
frame.GetXaxis().SetLabelSize(labelsize)
frame.GetYaxis().SetLabelSize(labelsize)
frame.GetXaxis().SetTitleSize(titlesize)
frame.GetYaxis().SetTitleSize(titlesize)
canv_mcorr = R.TCanvas('canv_mcorr','multipad',0,0,700,500)
pad1 = R.TPad("pad1","pad1", 0, 0.3, 1, 1) #xlow, ylow, xup, yup
pad2 = R.TPad("pad2","pad2", 0, 0 ,1, 0.3)
pad1.Draw()
pad2.Draw()
pad1.cd()
set_canvas_margins(pad1, bottom=0)
frame_mcorr = vars.at(0).frame()
frame_mcorr.SetTitle("")
pseudo_data.plotOn(frame_mcorr, RF.Name("data1D"))
pdf_model.plotOn(frame_mcorr, RF.Name("model1D"), RF.LineColor(mypalette[0]), RF.LineWidth(4))
plot_components(frame_mcorr, pdf_model, PDFdecays)
set_frame_axis(frame_mcorr)
frame_mcorr.Draw("")
pad2.cd()
set_canvas_margins(pad2, top=0, bottom=0.3, plot_ylog=False)
h_pull = frame_mcorr.pullHist('data1D', 'model1D')
frame_resid = vars.at(0).frame()
frame_resid.addPlotable(h_pull, "P")
frame_resid.SetTitle("")
frame_resid.GetYaxis().SetTitle("Residuals")
set_frame_axis(frame_resid, labelsize=labelsize_root*2, titlesize=titlesize_root*2, plot_ylog=False)
frame_resid.Draw("")
canv_mcorr.Close()
ROOT 6.32.02
Built for linuxx8664gcc on Jul 08 2024, 10:25:47
From heads/master@tags/v6-32-02