Drawing two or more histograms in a same canvas


I’d like to know a simple way to draw two histograms for example, in a same canvas. I want to draw one histogram and the other histogram with a line, both in the same canvas. I’ve tried to use THStack but I can’t. Now I’m trying to Draw one first and the other after, but I’m having problems with that. Is there a better way or more ellegant to do that?

Thank you very much for the attention!


What did you actually try? Did you do? :

h1->Draw(); h2->Draw("same");Philippe

1 Like

Yes, Yes, I did that!

I’ve tried this in the command line with two histograms to view the result and works, but then in my script it doesn’t work, surely I’m doing something wrong.

I’d like to ask another questions.

What’s the difference between AddBinContent y SetBinContent?

And, why when I add an error bar to each bin of a histogram, the histogram appears in a Canvas like a simple graph, not with the rectangles, and when I don’t add an error bar to the bin, appears the classical view of an histogram, with “stairs”? I’d like to view the histograms like graphs, not like a classical histogram.