# Opening two .root file in the same canvas

**URL:** <https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562>\
**Category:** ROOT\
**Created:** [June 9, 2011, 8:52am UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562 "2011-06-09T08:52:56Z")\
**Posts on this page:** 8\
**Page:** 2

<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:** [June 10, 2011, 1:34pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/21 "2011-06-10T13:34:32Z")

</div>

Sorry, in the previous macro you should do:

st-\>Draw(“nostack”);

instead of:

st-\>Draw();

You will get this:  
 ![](https://root-forum.cern.ch/uploads/default/original/2X/c/c7b88420f395b014c46e455aef86abeda062490d.gif)

---

<div class="post-metadata">

**Author:** ![baharan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/e56c9b/32.png) [@baharan](https://root-forum.cern.ch/u/baharan)\
**Post date:** [June 11, 2011, 9:29am UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/22 "2011-06-11T09:29:37Z")

</div>

Great Thanks for your Help

---

<div class="post-metadata">

**Author:** ![baharan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/e56c9b/32.png) [@baharan](https://root-forum.cern.ch/u/baharan)\
**Post date:** [June 14, 2011, 10:06am UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/23 "2011-06-14T10:06:20Z")

</div>

Hello again,

Could you please also kindly help me in how to put label for my axes in ur script?

Thank you in advance

---

<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:** [June 14, 2011, 12:50pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/24 "2011-06-14T12:50:14Z")

</div>

You mean axis title ?  
it is something like:  
h-\>GetXaxis()-\>SetTitle(…);  
Check the doc …

---

<div class="post-metadata">

**Author:** ![baharan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/e56c9b/32.png) [@baharan](https://root-forum.cern.ch/u/baharan)\
**Post date:** [June 14, 2011, 3:38pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/25 "2011-06-14T15:38:23Z")

</div>

Yes I meant axis titles.  
Could you please have a look at the enclosed script. I added the axis titles as well as another box using

[code]pt = new TPaveText(0.20,0.7,0.5,0.87, “NDC”);

text = pt-\>AddText(“Energy Deposition”);[/code]

But while I run essai2.C no change is observable!  
[essai2.C](https://root-forum.cern.ch/uploads/default/original/2X/7/7bc76c1a7494a52a8932042de51fc488f71d3488.C) (827 Bytes)

---

<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:** [June 14, 2011, 3:58pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/26 "2011-06-14T15:58:35Z")

</div>

```auto
{
   TFile f1("essai1.root");
   TH1D *h1=f1.Get("2");
   TFile f2("essai2.root");
   TH1D *h2=f2.Get("2");
   TFile f3("essai3.root");
   TH1D *h3=f3.Get("2");
   
   h2->SetLineColor(kRed);
   h3->SetLineColor(kGreen);

   h1->SetTitle("Galactic emlivermore and elastic");
   h2->SetTitle("water emlivermore and elastic");   
   h3->SetTitle("water emlivermore");

   THStack *st = new THStack();
   st->Add(h1);
   st->Add(h2);
   st->Add(h3);

   st->Draw("nostack");
   
   st->GetXaxis()->SetTitle("This is my X title");
   st->GetYaxis()->SetTitle("This is my Y title");
   
   gPad->BuildLegend();
}

```

---

<div class="post-metadata">

**Author:** ![Malek\_M\_R](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Malek\_M\_R](https://root-forum.cern.ch/u/Malek_M_R)\
**Post date:** [September 30, 2017, 5:20pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/27 "2017-09-30T17:20:59Z")

</div>

I have the same thing here … I would like to join two files together … I am using GAMOS and ROOT …

I actually have no knowledge about ROOT at all … I only get histograms from GAMOS …

GAMOS outputs histograms in ROOT format … Each run produces one histogram.root

I would really appreciate it if someone teaches me this step by step … The things said about are OK to me , but where do I type all of these lines ? Right in terminal ?

Also, I am not sure I should know how to code in C++ to do any of the things said above … Please advise …

Thanks,

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 30, 2017, 5:34pm UTC](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/28 "2017-09-30T17:34:00Z")

</div>

[ROOT User Guides and Manuals](https://root.cern.ch/root-user-guides-and-manuals)

[Previous page](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562.md?page=1)
