Error plotting three histograms in same pad

Dear experts,

I am trying to plot three histograms in the same canvas but I always get the last one of them. I don’t understand what I am doing wrong. I leave here the part of the code for plotting the hists.

C = TCanvas()
ht = h2dt.ProjectionY("",14,15)
ht.SetMarkerColor(kRed)
ht.SetLineStyle(1)
ht.SetLineColor(kRed)
ht.SetLineWidth(2)
ht.GetYaxis().SetRangeUser(0,0.75)
ht.SetTitle(";#tau (H_{0}) [ps];Vertex proportion")
ht.SetStats(0)                                                                                                                      

hd = h2dd.ProjectionY("",14,15)
hd.SetMarkerColor(kBlue)
hd.SetLineStyle(1)
hd.SetLineColor(kBlue)
hd.SetLineWidth(2)
hd.GetYaxis().SetRangeUser(0,0.75)
hl = h2dl.ProjectionY("",14,15)
hl.SetMarkerColor(kBlack)
hl.SetLineStyle(1)
hl.SetLineColor(kBlack)
hl.SetLineWidth(2)
hl.GetYaxis().SetRangeUser(0,0.75)

ht.Draw("HIST")
hd.Draw("SAME HIST")
hl.Draw("SAME HIST")

I also leave the file. I am working with pyroot on lxplus.
gen1d.py (14.0 KB)

The histograms are got from 2D histograms by projecting. All the code above these commands works fine I believe

Try with:

ht = h2dt.ProjectionY("ht",14,15)
hd = h2dd.ProjectionY("hd",14,15)
hl = h2dl.ProjectionY("hl",14,15)

Yes! It worked! Thanks a lot for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.