Hello,
I’m having what I think is a simple problem with TRatioPlot. If I set the TitleSize of the three axes (Upper and Lower y axis; Lower x axis) too large, the labels are partially cut out of the final plot. That is: I need to tell TRatioPlot to increase the canvas/pad sizes to accommodate the larger sized titles.
I tried a lot of options but couldn’t get it to work.
I attach a self contained python3 script which will reproduce the problem.
In the script titlesize=0.06 leads to titles outside of the canvas while titlesize=0.04 seems fine.
I know one can fudge with offsets (in the actual plot I’m trying to generate this is not enough) but I’d like to understand how to increase the size of the canvas/pad itself.
Thanks!
Enrico
Example:
#!/opt/homebrew/bin/python3
import sys, os, shutil
import ROOT as ROOT
from ROOT import *
ROOT.gStyle.SetOptStat(111110)
ROOT.gROOT.SetBatch(kTRUE)
ROOT.gStyle.SetTitleFontSize(0.08)titlesize = 0.06
c1 = ROOT.TCanvas(“c1”,“c1”)
h1 = ROOT.TH1F(‘h1’,‘h1_name’,100,-3,3)
h1.FillRandom(“gaus”, 200000)
h1.Scale(1.0/h1.Integral(), “width”)
h1.SetLineColor(kRed)
h1.SetStats(False)
h1.GetXaxis().SetRangeUser(-3,3)
h1.GetYaxis().SetRangeUser(0,0.5)
h1.SetTitle(“TITLE”)
h1.SetXTitle(“xtitle”)h2 = ROOT.TH1F(‘h2’,‘h2_name’,100,-3,3)
h2.FillRandom(“gaus”, 200000)
h2.Scale(1.0/h2.Integral(), “width”)
h2.SetLineColor(kBlue)rp = TRatioPlot(h1, h2)
rp.SetH1DrawOpt(“HIST E”)
rp.Draw()
rp.GetLowerRefGraph().SetMinimum (0.5)
rp.GetLowerRefGraph().SetMaximum (1.5)
rp.GetUpperRefYaxis().SetTitle(“upper”)
rp.GetLowerRefYaxis().SetTitle(“lower”)if titlesize is too large it is cut out of the canvas
rp.GetUpperRefYaxis().SetTitleSize(titlesize)
rp.GetLowerRefYaxis().SetTitleSize(titlesize)
rp.GetLowerRefXaxis().SetTitleSize(titlesize)gPad.Update()
c1.Print(“test_ratioplot.pdf”)
_ROOT Version:6.26/06
_Platform: MacOS
_Compiler: python3
test_ratioplot.pdf (29.2 KB)