# Drawing TGraph over THStack

**URL:** <https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544>\
**Category:** Newbie\
**Created:** [August 29, 2021, 6:32pm UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544 "2021-08-29T18:32:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francisco\_Lopez\_Gome](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/francisco_lopez_gome/32/27221_2.png) [@Francisco\_Lopez\_Gome](https://root-forum.cern.ch/u/Francisco_Lopez_Gome)\
**Post date:** [August 29, 2021, 6:32pm UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/1 "2021-08-29T18:32:07Z")

</div>

Hi there

I have two figures,

 ![1](https://root-forum.cern.ch/uploads/default/original/3X/3/2/32fd34317c74c3e6f63ee386c30e9c68c3b4cd79.png)  
 ![2](https://root-forum.cern.ch/uploads/default/original/3X/b/6/b607540dc468a430f7b2bebdd8e0fdd1fc34c488.png)

one created with THStack and the ohter with TMultiGraph  
Is there any way to combine the stack with one of the TGraphs which i use in the figure in the same canvas? I tried to use the Draw(“SAME”) option in the TGraph but doesn’t work

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 30, 2021, 4:52am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/2 "2021-08-30T04:52:06Z")

</div>

What do you mean by “doesn’t work”? what do you get? and showing the code you used would also help… In any case, “same” is not an option for graphs; by default they are drawn on the same existing canvas/pad, unless you give the option “A” (axes); maybe you want to draw with the option “L” (line) only.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 30, 2021, 8:24am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/3 "2021-08-30T08:24:28Z")

</div>

Send us a reproducer.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 30, 2021, 8:30am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/4 "2021-08-30T08:30:51Z")

</div>

Hi @Francisco_Lopez_Gome ,  
and welcome to the ROOT forum!

Just to clarify, if @dastudillo 's suggestion does not help, indeed we need a minimal reproducer – that is a little self-contained piece of code that shows what the issue is and that we can fix to show you how to get the plot you want.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Francisco\_Lopez\_Gome](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/francisco_lopez_gome/32/27221_2.png) [@Francisco\_Lopez\_Gome](https://root-forum.cern.ch/u/Francisco_Lopez_Gome)\
**Post date:** [August 31, 2021, 7:00am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/5 "2021-08-31T07:00:00Z")

</div>

Oh ok sry,here is  
[Data.C](https://root-forum.cern.ch/uploads/short-url/hLhECF4If7CWSMJLfxHT2Ac3oBg.C) (11.0 KB)  
and data  
[NeutrinoXenontest.txt](https://root-forum.cern.ch/uploads/short-url/pr0DhvBjkQbWv8zg3JlwMOeCYxd.txt) (2.8 KB)  
[Xe-10-5-Cu-1data.txt](https://root-forum.cern.ch/uploads/short-url/bKFsrgIHKPZvamQ4kscGQbPOIvS.txt) (3.2 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 31, 2021, 7:24am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/6 "2021-08-31T07:24:30Z")

</div>

You should first draw the stack then the graph.

```auto
  c1->cd();
  TH1D *last=(TH1D*)hs->GetStack()->Last(); hs->SetMaximum((1.25)*(last->GetBinContent(last->GetMaximumBin()))); hs->Draw("HIST BAR");
  g->Draw("C");

```

 ![Screenshot 2021-08-31 at 09.22.46](https://root-forum.cern.ch/uploads/default/original/3X/9/a/9ae2e8867adaa7e7e552c86fe39631fb8c9d8e94.jpeg)

---

<div class="post-metadata">

**Author:** ![Francisco\_Lopez\_Gome](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/francisco_lopez_gome/32/27221_2.png) [@Francisco\_Lopez\_Gome](https://root-forum.cern.ch/u/Francisco_Lopez_Gome)\
**Post date:** [August 31, 2021, 7:32am UTC](https://root-forum.cern.ch/t/drawing-tgraph-over-thstack/46544/7 "2021-08-31T07:32:29Z")

</div>

Thank you sou much @couet, it works
