# Failed to set title of TGraph

**URL:** <https://root-forum.cern.ch/t/failed-to-set-title-of-tgraph/55020>\
**Category:** Newbie\
**Tags:** root\
**Created:** [May 25, 2023, 12:14am UTC](https://root-forum.cern.ch/t/failed-to-set-title-of-tgraph/55020 "2023-05-25T00:14:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [May 25, 2023, 12:14am UTC](https://root-forum.cern.ch/t/failed-to-set-title-of-tgraph/55020/1 "2023-05-25T00:14:36Z")

</div>

Dear Experts

I want to set titles of graphs which I drawn on the same canvas, here is what I tried, but the title didn’t appear. Can you suggest me which procedure I’m missing?

```auto
root -l somefile.root

//in the root UI
Canvas* c = new TCanvas();
c->Divide(4,2);
//code below was in a single line, but for easier reading I put them different lines
for(int i=0; i<8; ++i){ 
    c->cd(i+1); gPad->DrawFrame(0, -0.7, 1000, 0.2);
    t->Draw(Form("vol_%d:Iteration$", i+1), "", "LSAME", 1, 0); 
    auto graph = (TGraph*)gPad->GetPrimitive("Graph"); 
    graph->SetTitle(Form("waveform ch.%d", i)); 
    graph->GetXaxis()->SetTitle("sample"); 
    graph->GetYaxis()->SetTitle("Voltage [V]"); 
    gPad->Modified(); 
    gPad->Update();
}

```

---

<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 25, 2023, 6:46am UTC](https://root-forum.cern.ch/t/failed-to-set-title-of-tgraph/55020/2 "2023-05-25T06:46:38Z")

</div>

`gPad->DrawFrame(0., -0.7, 1000., 0.2, TString::Format("waveform ch.%d;sample;Voltage [V]", i));`

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [May 25, 2023, 7:14am UTC](https://root-forum.cern.ch/t/failed-to-set-title-of-tgraph/55020/3 "2023-05-25T07:14:19Z")

</div>

Didn’t know such elegant method! Thank you 🙂
