# More than one graph in a Canvas

**URL:** <https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559>\
**Category:** ROOT\
**Created:** [June 8, 2011, 3:15pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559 "2011-06-08T15:15:56Z")\
**Posts on this page:** 5\
**Page:** 1

<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 8, 2011, 3:15pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559/1 "2011-06-08T15:15:56Z")

</div>

Greetings root users,

Could any one kindly help me and say how I can have different graphs in a single Canvas, in order to be able to compare them and label them?

Thnak you in advance

---

<div class="post-metadata">

**Author:** ![pacher](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@pacher](https://root-forum.cern.ch/u/pacher)\
**Post date:** [June 8, 2011, 5:57pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559/2 "2011-06-08T17:57:57Z")

</div>

Create a TCanvas and divide it into Pads using the TCanvas::Divide() method, for instance if plot1 and plot2 are two TGraph graphics and histo is a TH1 histogram write:

```auto
TCanvas *cvs = new TCanvas("cvs","A title...");
cvs->Divide(2,2);
cvs->cd(1);
.....
..... // options
plot1->Draw();

cvs->cd(2);
.....
.....
plot2->Draw();

cvs->cd(3);
.....
.....
histo->Draw();

```

---

<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 9, 2011, 12:49pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559/3 "2011-06-09T12:49:42Z")

</div>

Hej Again,

I felt I’d better attach my files for a better reference. each file contain three histograms. but I want to compare all the number 2s for example.

Many thanks again  
[essai3.root](https://root-forum.cern.ch/uploads/default/original/2X/0/0e84fdc9e242c89f3b0c90f881bed5c4e1c3b1f0.root) (9.13 KB)  
[essai2.root](https://root-forum.cern.ch/uploads/default/original/2X/a/ad79d0bdfcb2453dd629381057a3f1bf8064880d.root) (9.74 KB)  
[essai1.root](https://root-forum.cern.ch/uploads/default/original/2X/8/83b3deaba6893e122a64887439d385c3d45c433f.root) (9.78 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:** [June 20, 2011, 1:01pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559/4 "2011-06-20T13:01:08Z")

</div>

Hi,

What did you try? How did it fail?

Philippe.

---

<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 20, 2011, 1:53pm UTC](https://root-forum.cern.ch/t/more-than-one-graph-in-a-canvas/12559/5 "2011-06-20T13:53:22Z")

</div>

Philippe,

I think you can ignore this post. I have already answered this question (and many more !) here:

> [@Opening two .root file in the same canvas](https://root-forum.cern.ch/t/opening-two-root-file-in-the-same-canvas/12562/1):
>
> Hi Every Body, I have two .root files including histograms. I got them from AIDA in geant4. For opening these files I need root. I need to open these two files in one canvas in order to be able to compare them. I am wondering should I write a c++ code for that or can I do it easily from the browser? Really thank for your help

Olivier
