Hi!
I am trying to do a ratio plot, but when I change set the title size or font on the lower pad, “pad_rat1”, the x-axis the title disappears. The code is below, do you know why this happens?
g_rat_mg.GetXaxis().SetTitleFont(42) #This makes the title disappear. If I comment it out it draws the title, but I can’t change the size or font.
Also (not as important), the setRangeUser(x1, x2) for the above pad and pad below gives different ranges. The one above gives exactly what I set it to while the one below adds a little bit to the range. Do you know why?
Thanks a lot!
#Parts of the code#
def graph4():
c1 = r.TCanvas("c1","Graphs",700,700)
c1.cd()
p1 = r.TPad("p1","p1",0.,0.35,1.,1.)
p1.Draw()
p1.SetBottomMargin(0.001)
p1.cd()
#p1.SetGrid()
p1.SetLogy()
c1.cd()
p2 = r.TPad("p2","p2",0., 0.07, 1., 0.32)#xmin,ymin,xmax,ymax
p2.Draw()
p2.SetTopMargin(0.001)
p2.SetBottomMargin(0.3)
#p2.SetGrid()
p2.cd()
return c1, p2 , p1
def main (..):
g1_mg = r.TMultiGraph()
canv_rat1, pad_rat1, pad_roc = graph4()
canv_rat1.cd()
pad_roc.cd()
for m in range(len(graph_vec)):
graph_vec[m].SetLineColor(int(plotDict_TVA[tva_vec[m]].color))
graph_vec[m].SetLineWidth(2)
graph_vec[m].GetYaxis().SetTitleSize(0.5)
g1_mg.Add(graph_vec[m])
g1_mg.GetXaxis().SetRangeUser(0.843,0.9845)
g1_mg.GetYaxis().SetTitleSize(25);
g1_mg.GetYaxis().SetTitleFont(43);
g1_mg.GetYaxis().SetTitleOffset(1.4);
g1_mg.GetYaxis().SetTitle("something")
g1_mg.Draw("L SAME")
## Ratio Pad
g_rat_mg = r.TMultiGraph()
g_rat_mg.Add(gr_ratio1)
g_rat_mg.Add(gr_ratio2)
pad_rat1.cd()
#Ratio y-axis
g_rat_mg.GetYaxis().SetTitleFont(43)
g_rat_mg.GetYaxis().SetTitleSize(18)
g_rat_mg.GetYaxis().SetTitleOffset(1.8)
g_rat_mg.GetYaxis().SetTitle("Ratio to 3 mm")
g_rat_mg.GetYaxis().CenterTitle()
g_rat_mg.GetYaxis().SetLabelFont(43)
g_rat_mg.GetYaxis().SetLabelSize(15)
g_rat_mg.GetYaxis().SetNdivisions(5)
#Ratio x-axis
#This part does not work
g_rat_mg.GetXaxis().SetTitleFont(42) #This makes the title disappear. If I comment it out it draws the title.
g_rat_mg.GetXaxis().SetTitleSize(10)
g_rat_mg.GetXaxis().SetTitleOffset(1.1)
g_rat_mg.GetXaxis().SetLabelFont(42)
g_rat_mg.GetXaxis().SetLabelSize(15)
g_rat_mg.GetXaxis().SetTitle("x-axis title") # If I only use this line and comment out the other it draws it.
g_rat_mg.GetXaxis().SetNdivisions(414)
g_rat_mg.GetXaxis().SetRangeUser(0.85,0.98) #This does not work. It adds a bit to the range
g_rat_mg.GetXaxis().SetTickSize(0.01)
g_rat_mg.Draw("L SAME")
canv_rat1.SaveAs (args.output_dir + '/' + outputname + '.pdf')