Drawing TGraph over THStack

Hi there

I have two figures,


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

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.

2 Likes

Send us a reproducer.

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

Oh ok sry,here is
Data.C (11.0 KB)
and data
NeutrinoXenontest.txt (2.8 KB)
Xe-10-5-Cu-1data.txt (3.2 KB)

You should first draw the stack then the graph.

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

Thank you sou much @couet, it works