# Plotting three leafs in one canvas

**URL:** <https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999>\
**Category:** Newbie\
**Tags:** tree, graphics, root\
**Created:** [November 5, 2023, 8:02pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999 "2023-11-05T20:02:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wandelsterne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/71c47a/32.png) [@Wandelsterne](https://root-forum.cern.ch/u/Wandelsterne)\
**Post date:** [November 5, 2023, 8:02pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999/1 "2023-11-05T20:02:29Z")

</div>

Hi,  
I only recently started using root so I’m currently very confused.  
I have three root files, where I want to extract the leaf (?) integral[0] for these three files and then draw them all in one picture.  
extracting integral[0] and drawing that for one file is seemingly easy with

```auto
TFile *file=new TFile("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root")
(TFile *) 0x7fe87552dfc0
root [26] resultTree->Draw("integral[0]")

```

can anyone help me how I do this for three different files (they all have that leaf). I haven’t really found anything on the internet, and chatgpt also couldn’t help me. I would really appreciate the help

_ROOT Version:_ 6.26.11  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Wandelsterne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/71c47a/32.png) [@Wandelsterne](https://root-forum.cern.ch/u/Wandelsterne)\
**Post date:** [November 5, 2023, 8:21pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999/2 "2023-11-05T20:21:37Z")

</div>

oh also I use the command line, so each “sentence” of my code is read separately. I don’t know how to change that, because chatgpt has given me codes where there are syntax differences and such and I can’t really compute that…

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 5, 2023, 8:40pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999/3 "2023-11-05T20:40:49Z")

</div>

```auto
TChain ch("resultTree");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/second_file.root");
ch.Add("Documents/Bachelor/1. Messung 3.11.23/third_file.root");
ch.Draw("integral[0]");

```

---

<div class="post-metadata">

**Author:** ![Wandelsterne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/71c47a/32.png) [@Wandelsterne](https://root-forum.cern.ch/u/Wandelsterne)\
**Post date:** [November 5, 2023, 8:47pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999/4 "2023-11-05T20:47:56Z")

</div>

this gave me a result, thank you. however, I’m a bit confused by the result, haha. would it be possible to differentiate between the three files in the canvas? I don’t know if what is shown, is even correct tbh  
[falsch?.pdf](https://root-forum.cern.ch/uploads/short-url/rGIIpbohDtlDDUJNahl2FxKgGjL.pdf) (16.2 KB)

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 5, 2023, 9:37pm UTC](https://root-forum.cern.ch/t/plotting-three-leafs-in-one-canvas/56999/5 "2023-11-05T21:37:01Z")

</div>

> [@Wandelsterne](#):
>
> would it be possible to differentiate between the three files in the canvas?

Yes.

```auto
TChain ch1("resultTree");
ch1.Add("Documents/Bachelor/1. Messung 3.11.23/1675V_9909_1photonevent_55tune_short.root");
TChain ch2("resultTree");
ch2.Add("Documents/Bachelor/1. Messung 3.11.23/second_file.root");
TChain ch3("resultTree");
ch3.Add("Documents/Bachelor/1. Messung 3.11.23/third_file.root");
ch1.Draw("integral[0]");
ch2.Draw("integral[0]", "", "SAME");
ch3.Draw("integral[0]", "", "SAME");

```

> I don’t know if what is shown, is even correct tbh

Only you or the original author of the file might know that.
