How to change marks for line bars curve

Hello,

I’m drawing some overlay-ed histograms (two histogram in one) like you can see in the attached image

How can i change the red curve from marks to a lines bars with pyroot?. The histograms are TEfficiency class, so there is less direct methods to do this.

Thanks in advance


Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.26/08
_Platform: Linux 20.04 LTS
_Compiler: python 3.8.10


Try to Draw your plots using option “L” .

Hello,

The option “L” does not work property to my. i get this

Captura desde 2022-11-14 18-03-29

but i want this format (type of curve)

Captura desde 2022-11-14 18-05-19

Try: "HIST"

If you send a small reproducer we could help you more efficiently.

Hello,

This is the function that i use to write the overlayed histograms.

def overplot(h1,h2,spec1,spec2,opath,n):
    c1 = R.TCanvas()
    c1.SetTickx()
    c1.SetTicky()
    c1.SetLeftMargin(0.1)
    c1.SetRightMargin(0.18)
    if h1.IsA().InheritsFrom("TEfficiency") == True and h2.IsA().InheritsFrom("TEfficiency") == True:
#       h1.SetMarkerStyle(24)
        h2.SetMarkerStyle(25)
#       h1.SetMarkerColorAlpha(R.kBlack,0.99)
        h2.SetMarkerColorAlpha(R.kBlue,0.8)
#       h1.SetLineColor(R.kBlack)
        h2.SetLineColor(R.kBlue)
        h11=h1.GetPassedHistogram()
        h22=h2.GetPassedHistogram()
        chi2=h11.Chi2Test(h22,"UU")
#       h1.GetListOfFunctions().AddFirst(hh1)
        latex=R.TLatex()
        latex.SetTextSize(0.05)
        if h1.GetName()=="EffHLT_tauPt_wrt_Offline":
            c1.DrawFrame(0,0,350,1.5)
            latex.DrawLatex(30,1.25,"#chi^{2}="+str(chi2)[0:7])
        elif h1.GetName()=="EffHLT_averageMu_wrt_Offline":
            c1.DrawFrame(0,0.2,65,1.4)
        elif h1.GetName()=="EffHLT_tauEta_wrt_Offline":
            c1.DrawFrame(-3.5,0.65,3.5,1.25)
        elif h1.GetName()=="EffHLT_tauPhi_wrt_Offline":
            c1.DrawFrame(-3.5,0.72,3.5,1.25)
        elif h1.GetName()=="EffHLT_tauPt_coarse_wrt_Offline":
            c1.DrawFrame(0,0.65,550,1.4)
        h1.Draw("HIST")
        h2.Draw("SAME1")
        if h1.GetName()=="EffHLT_tauPt_wrt_Offline":
            h3=R.TLine(n,0,n,1.1)
            h3.SetLineColor(R.kRed)
            h3.Draw("SAME1")
        legend=R.TLegend(0.38,0.7,0.8,0.85)
        legend.AddEntry(h1,spec1,"LEP")
        legend.AddEntry(h2,spec2,"LEP")
        legend.SetBorderSize(0)
        legend.Draw()
        c1.Print(opath+"/"+h1.GetName()+".png")
    elif h1.InheritsFrom("TTree")==False and h2.InheritsFrom("TTree")==False:
        h1.SetFillColor(R.kRed)
        h2.SetFillColor(R.kBlue)
        if h1.GetMaximumBin()>h2.GetMaximumBin():
            h1.Draw("SAME4")
            h2.Draw("SAME4")
        else:
            h2.Draw("SAME4")
            h1.Draw("SAME4")
        legend=R.TLegend(0.6,0.9,1,1)
        legend.AddEntry(h1,spec1,"L")
        legend.AddEntry(h2,spec2,"L")
        legend.Draw()
        hist_name = opath+h1.GetName()+".png"
        c1.Print(opath+"/"+h1.GetName()+".png")
        
    c1.Update()
    c1.Clear()
    return

it’ would be great to get the curve like in the previous comment.

h1.Draw("HIST L")

it does not look nice

Captura desde 2022-11-15 13-11-00

how can avoid the vertical lines of uncertainty?

Ok, can you put in a ROOT file the two histograms you are plotting and I will look ?

Hello @couet ,

Here it is.

file_output.root (5.7 KB)

Cheers

does someone know how to retrieve histogram date from the TEfficiency histogram and calculate the Xi2Square test between both? (with python)

I think @moneta can help with this.

Your objects are not histogram but TEfficiency. The drawing is done as said in the section VI.3 in the TEfficiency documentation.