# Beginner: SetTitle in canvas doesn' t work

**URL:** <https://root-forum.cern.ch/t/beginner-settitle-in-canvas-doesn-t-work/57070>\
**Category:** Newbie\
**Created:** [November 10, 2023, 8:25am UTC](https://root-forum.cern.ch/t/beginner-settitle-in-canvas-doesn-t-work/57070 "2023-11-10T08:25:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafal4](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rafal4](https://root-forum.cern.ch/u/rafal4)\
**Post date:** [November 10, 2023, 8:25am UTC](https://root-forum.cern.ch/t/beginner-settitle-in-canvas-doesn-t-work/57070/1 "2023-11-10T08:25:42Z")

</div>

Hello,

I am beginner in ROOT. I need to write simple macro. I am trying set title and name in Canvas but it is not correct.  
Can anyone tell me how to correctly add a title and name in Canvas?  
Thank you and best regards

```auto
void macros1() {
TFile f("Pion1GeV.root");
TTree * evt = (TTree*)f.Get("evt");

TCanvas c1("Pion E=1GeV", "Pion E=1GeV; z; x:z", 1600, 1000);
evt->Draw("x:z");
c1.SetTitle("Pion, E=1GeV");//doesn't work
c1.SetName("Pion, E=1GeV");//doesn't work
f.Close();
c1.SaveAs("Pion1GeV.png");
}

```

---

<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:** [November 10, 2023, 9:18am UTC](https://root-forum.cern.ch/t/beginner-settitle-in-canvas-doesn-t-work/57070/2 "2023-11-10T09:18:59Z")

</div>

Welcome to the ROOT forum.

```auto
evt->GetHistogram()->SetTitle("Pion, E=1GeV");

```

---

<div class="post-metadata">

**Author:** ![rafal4](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rafal4](https://root-forum.cern.ch/u/rafal4)\
**Post date:** [November 10, 2023, 8:39pm UTC](https://root-forum.cern.ch/t/beginner-settitle-in-canvas-doesn-t-work/57070/3 "2023-11-10T20:39:26Z")

</div>

Now it is working ! Thank you very much Olivier Couet !
