# Plotting multiple histograms on the same canvas in PyROOT Jupyter notebook

**URL:** <https://root-forum.cern.ch/t/plotting-multiple-histograms-on-the-same-canvas-in-pyroot-jupyter-notebook/42356>\
**Category:** Newbie\
**Tags:** graphics, python, hist\
**Created:** [November 18, 2020, 7:33pm UTC](https://root-forum.cern.ch/t/plotting-multiple-histograms-on-the-same-canvas-in-pyroot-jupyter-notebook/42356 "2020-11-18T19:33:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![slipper](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/slipper/32/24026_2.png) [@slipper](https://root-forum.cern.ch/u/slipper)\
**Post date:** [November 18, 2020, 7:33pm UTC](https://root-forum.cern.ch/t/plotting-multiple-histograms-on-the-same-canvas-in-pyroot-jupyter-notebook/42356/1 "2020-11-18T19:33:42Z")

</div>

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)  
hist1.Draw()  
hist2.Draw(“same”)  
hist3.Draw(“same”)  
canv.Draw()

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

I also tried:

stack = ROOT.THStack(“stack”,“stack”)  
stack.Add(hist1)  
stack.Add(hist2)  
stack.Add(hist3)  
canv2 = ROOT.TCanvas(“stackcanvas”,“Stack canvas”,800,400)  
stack.Draw()  
canv2.Draw()

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 😃

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [November 19, 2020, 8:44am UTC](https://root-forum.cern.ch/t/plotting-multiple-histograms-on-the-same-canvas-in-pyroot-jupyter-notebook/42356/2 "2020-11-19T08:44:01Z")

</div>

Hi!

`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](https://root.cern.ch/doc/master/classTHStack.html), 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?

---

<div class="post-metadata">

**Author:** ![slipper](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/slipper/32/24026_2.png) [@slipper](https://root-forum.cern.ch/u/slipper)\
**Post date:** [November 19, 2020, 9:24am UTC](https://root-forum.cern.ch/t/plotting-multiple-histograms-on-the-same-canvas-in-pyroot-jupyter-notebook/42356/3 "2020-11-19T09:24:43Z")

</div>

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