import ROOT
x = ROOT.RooRealVar("x", "x", -10, 10)
sigma = ROOT.RooRealVar("sigma", "sigma", 1, 0.1, 10)
mean = ROOT.RooRealVar("mean", "mean", -3, -10, 10)
gauss = ROOT.RooGaussian("gauss", "gauss", x, mean, sigma)
data = gauss.generate({x}, 1000)
gauss.fitTo(data, PrintLevel=-1)
frame = x.frame(Name="xframe", Title="RooPlot with decorations", Bins=40)
data.plotOn(frame)
gauss.plotOn(frame)
gauss.paramOn(frame, Layout=0.55)
data.statOn(frame, Layout=(0.55, 0.99, 0.8))
txt = ROOT.TText(2, 100, "Signal")
txt.SetTextSize(0.04)
txt.SetTextColor(ROOT.kRed)
frame.addObject(txt)
arrow = ROOT.TArrow(2, 100, -1, 50, 0.01, "|>")
arrow.SetLineColor(ROOT.kRed)
arrow.SetFillColor(ROOT.kRed)
arrow.SetLineWidth(3)
frame.addObject(arrow)
f = ROOT.TFile("rf106_plotdecoration.root", "RECREATE")
frame.Write()
f.Close()
c = ROOT.TCanvas("rf106_plotdecoration", "rf106_plotdecoration", 600, 600)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.6)
frame.Draw()
c.SaveAs("rf106_plotdecoration.png")