# Draw multiple root files along with graph file on the same canvas

**URL:** <https://root-forum.cern.ch/t/draw-multiple-root-files-along-with-graph-file-on-the-same-canvas/34956>\
**Category:** Newbie\
**Created:** [July 2, 2019, 10:22am UTC](https://root-forum.cern.ch/t/draw-multiple-root-files-along-with-graph-file-on-the-same-canvas/34956 "2019-07-02T10:22:09Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [July 3, 2019, 6:11am UTC](https://root-forum.cern.ch/t/draw-multiple-root-files-along-with-graph-file-on-the-same-canvas/34956/3 "2019-07-03T06:11:14Z")

</div>

Hi,  
since in your first.root file have no canvas you have to get the histogram.

```auto
TFile *f1 = TFile::Open(“first.root”);
TH1D *h2 = (TH1D)f1->Get(“h2”);
h2->SetName("F");
h2->Draw(“hist same”);
h2->SetLineColor(1);
h2->SetLineWidth(2);

```

almost the same problem is addressed here

> [@Draw two histograms in same canvas from two different root files](https://root-forum.cern.ch/t/draw-two-histograms-in-same-canvas-from-two-different-root-files/34900/3):
>
> Hi, I attached below a modified version of your code. (Remember to put you code between two ``` in this way will appear highlited). there are 3 main point I added two ; after the opening of the files. When you use Get() to get the histogram recast as a TH1D and not a TCanvas, otherwise you cannot the TH1D methods. the Draw is made using the TH1D pointer and not the name of the histogram in the file. void macro() { TFile \*f1 = TFile::Open("first.root"); TH1D \*h1= (TH1D\*)f1…

Ciao,  
Stefano

---

_[View the full topic](https://root-forum.cern.ch/t/draw-multiple-root-files-along-with-graph-file-on-the-same-canvas/34956)._
