# Help with superimposing graphs

**URL:** <https://root-forum.cern.ch/t/help-with-superimposing-graphs/39568>\
**Category:** Newbie\
**Created:** [May 24, 2020, 11:54am UTC](https://root-forum.cern.ch/t/help-with-superimposing-graphs/39568 "2020-05-24T11:54:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 24, 2020, 11:54am UTC](https://root-forum.cern.ch/t/help-with-superimposing-graphs/39568/1 "2020-05-24T11:54:46Z")

</div>

```auto
void g3()
{
Int_t n = 20; 
Double_t x[n], y[n], x1[n], y1[n];

for (Int_t i=0; i<n; i++) 
 { 
x[i] = i*0.1; 
y[i] = 10*sin(x[i]+0.2); 
 }

for (Int_t j=0; j<n; j++) 
 { 
x1[j] = j*0.1; 
y1[j] = cos(x[j]); 
 }

TCanvas *c1 = new TCanvas ("c1","Graph Draw Options", 200,10,600,400);
TGraph *gr3 = new TGraph(n,x,y); 
gr3-> SetLineColor(4);
gr3->Draw("AC*");

TGraph *gr2 = new TGraph(n,x1,y1); 
gr2->SetLineWidth(3);
gr2->SetMarkerStyle(21);
gr2->SetLineColor(2);
gr2->Draw("CP");
}

```

* * *

I wrote this code to superimpose two graphs but it wont work and only shows one graph?

---

<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:** [May 24, 2020, 12:33pm UTC](https://root-forum.cern.ch/t/help-with-superimposing-graphs/39568/2 "2020-05-24T12:33:56Z")

</div>

[TMultiGraph](https://root.cern/doc/master/classTMultiGraph.html)
