Plotting multiple histograms on the same canvas in PyROOT Jupyter notebook

Hello! I’m using ROOT on a Jupyter notebook and I’m having some trouble plotting histograms on the same axes. I only started using ROOT 2 days ago so I’m still very new! I’ve tried two methods:

canv = ROOT.TCanvas(“newcanvas”,“New canvas”,800,600)

This seems to only plot histograms hist1 and hist2, not hist3

I also tried:

stack = ROOT.THStack(“stack”,“stack”)
canv2 = ROOT.TCanvas(“stackcanvas”,“Stack canvas”,800,400)

And this produces a graph which looks nothing like I expect! (presumably I have misunderstood the meaning of THStack or Add). The values that appear on the graph do not match up with those in the histogram.

Any advice would be greatly appreciated!
Thank you :smiley:


hist3 not being drawn sounds like a bug! I’ll check who of us can have a look.

For THStack, you did check the doc, right? 'Cause by default the histograms are stacked on top of each other, i.e. the bin values are added. "nostack" just overlays them. Is that the issue?

That sounds like the issue! I’ll check the doc again :smiley: Thank you so much!
EDIT: just had to add "no stack" and it works as expected, thank you again :smiley:

1 Like