I’ve attached a file here. Now, ignoring all other elements, the code is below. The problem is that I set the slope of a line I draw, on a TH2 with equal-length axes, to 1… I also SetTextAngle(45) for the text that I draw on. The line and the text seem to have different angles! Even more concerning, drawing the TH2 with the “TEXT45” option seems to have the text aligned with the line!
How can I get the “Kinematically Forbidden” text to line up? Is it a problem with aspect ratio? How do I fix this? I must be missing something stupid. Note, this is indeed pyroot, but reproducible in ROOT/C++ as well.
def nbins(start, stop, step):
return abs(int( (stop - start) / step ))
def axis_labels(x_label="m_{#tilde{g}} [GeV]", y_label="m_{#tilde{#chi}^{0}_{1}} [GeV]", z_label="", title=""):
return ';'.join([title, x_label, y_label, z_label])
c = ROOT.TCanvas("c", "", 0, 0, 800, 600)
c.SetTopMargin(0.07)
c.SetRightMargin(0.16)
hist = ROOT.TH2F(name,
axis_labels(z_label=label),
nbins(200, 2500, 100),
200,
2500,
nbins(0, 2300, 100),
0,
2300)
# fill hist here
hist.Draw("TEXT45 COLZ")
# draw line
l=ROOT.TLine(1000,1000,2000,2000)
l.SetLineStyle(2)
l.DrawLine(350, 0, 2500, 2150)
# Draw Kinematically Forbidden as well
txt = ROOT.TLatex()
txt.SetTextFont(12)
txt.SetTextAngle(45)
txt.SetTextSize(0.02)
txt.DrawText(1425, 1200, "Kinematically Forbidden")
c.SaveAs(savefilename + ".pdf")